public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/13502] New: SEGFAULT in fork() when pthread_atfork() was called from a library loaded/unloaded with dlopen/dlclose
@ 2011-12-15 12:17 olma_ru at yahoo dot com
  2011-12-15 12:18 ` [Bug libc/13502] " olma_ru at yahoo dot com
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: olma_ru at yahoo dot com @ 2011-12-15 12:17 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=13502

             Bug #: 13502
           Summary: SEGFAULT in fork() when pthread_atfork() was called
                    from a library loaded/unloaded with dlopen/dlclose
           Product: glibc
           Version: 2.12
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: drepper.fsp@gmail.com
        ReportedBy: olma_ru@yahoo.com
    Classification: Unclassified


Created attachment 6112
  --> http://sourceware.org/bugzilla/attachment.cgi?id=6112
reproducer

There is a shared library that calls pthread_atfork() (at least one handler
must be NOT NULL) during initialization.
There is an application that loads this shared library with dlopen() and then
unloads it with dlclose().
Then the application calls fork(). 
Segfault occurs.

It looks like atfork handlers registered with pthread_atfork() were not removed
during dlclose().

The problem can be reproduced with the attached test. 
Compile libfoo.c - "gcc -c -fPIC -o libfoo.o libfoo.c"
Create the shared library - "gcc -shared -o libfoo.so libfoo.o"
Compile fork_main.c - "gcc -o fork_main fork_main.c -ldl -lpthread"
Run ./fork_main.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libc/13502] SEGFAULT in fork() when pthread_atfork() was called from a library loaded/unloaded with dlopen/dlclose
  2011-12-15 12:17 [Bug libc/13502] New: SEGFAULT in fork() when pthread_atfork() was called from a library loaded/unloaded with dlopen/dlclose olma_ru at yahoo dot com
@ 2011-12-15 12:18 ` olma_ru at yahoo dot com
  2012-12-19 10:46 ` schwab@linux-m68k.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: olma_ru at yahoo dot com @ 2011-12-15 12:18 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=13502

Olga Malysheva <olma_ru at yahoo dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |olma_ru at yahoo dot com

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libc/13502] SEGFAULT in fork() when pthread_atfork() was called from a library loaded/unloaded with dlopen/dlclose
  2011-12-15 12:17 [Bug libc/13502] New: SEGFAULT in fork() when pthread_atfork() was called from a library loaded/unloaded with dlopen/dlclose olma_ru at yahoo dot com
  2011-12-15 12:18 ` [Bug libc/13502] " olma_ru at yahoo dot com
@ 2012-12-19 10:46 ` schwab@linux-m68k.org
  2013-09-21 20:21 ` neleai at seznam dot cz
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: schwab@linux-m68k.org @ 2012-12-19 10:46 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=13502

Andreas Schwab <schwab@linux-m68k.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|drepper.fsp at gmail dot    |unassigned at sourceware
                   |com                         |dot org

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libc/13502] SEGFAULT in fork() when pthread_atfork() was called from a library loaded/unloaded with dlopen/dlclose
  2011-12-15 12:17 [Bug libc/13502] New: SEGFAULT in fork() when pthread_atfork() was called from a library loaded/unloaded with dlopen/dlclose olma_ru at yahoo dot com
  2011-12-15 12:18 ` [Bug libc/13502] " olma_ru at yahoo dot com
  2012-12-19 10:46 ` schwab@linux-m68k.org
@ 2013-09-21 20:21 ` neleai at seznam dot cz
  2013-09-22  5:22 ` bugdal at aerifal dot cx
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: neleai at seznam dot cz @ 2013-09-21 20:21 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=13502

Ondrej Bilka <neleai at seznam dot cz> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |neleai at seznam dot cz

--- Comment #1 from Ondrej Bilka <neleai at seznam dot cz> ---
This problem cannot be solved without introducing new API.

Problem here is lack of function that removes fork handler.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libc/13502] SEGFAULT in fork() when pthread_atfork() was called from a library loaded/unloaded with dlopen/dlclose
  2011-12-15 12:17 [Bug libc/13502] New: SEGFAULT in fork() when pthread_atfork() was called from a library loaded/unloaded with dlopen/dlclose olma_ru at yahoo dot com
                   ` (2 preceding siblings ...)
  2013-09-21 20:21 ` neleai at seznam dot cz
@ 2013-09-22  5:22 ` bugdal at aerifal dot cx
  2013-10-03  1:17 ` carlos at redhat dot com
  2014-06-27 11:31 ` fweimer at redhat dot com
  5 siblings, 0 replies; 7+ messages in thread
From: bugdal at aerifal dot cx @ 2013-09-22  5:22 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=13502

Rich Felker <bugdal at aerifal dot cx> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugdal at aerifal dot cx

--- Comment #2 from Rich Felker <bugdal at aerifal dot cx> ---
Moreover, there's nothing safe that can be done from pthread_atfork handlers
anyway; the whole concept of pthread_atfork was a mistake, and this is largely
acknowledged in the Rationale section for pthread_atfork in POSIX.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libc/13502] SEGFAULT in fork() when pthread_atfork() was called from a library loaded/unloaded with dlopen/dlclose
  2011-12-15 12:17 [Bug libc/13502] New: SEGFAULT in fork() when pthread_atfork() was called from a library loaded/unloaded with dlopen/dlclose olma_ru at yahoo dot com
                   ` (3 preceding siblings ...)
  2013-09-22  5:22 ` bugdal at aerifal dot cx
@ 2013-10-03  1:17 ` carlos at redhat dot com
  2014-06-27 11:31 ` fweimer at redhat dot com
  5 siblings, 0 replies; 7+ messages in thread
From: carlos at redhat dot com @ 2013-10-03  1:17 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=13502

Carlos O'Donell <carlos at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |carlos at redhat dot com

--- Comment #3 from Carlos O'Donell <carlos at redhat dot com> ---
(In reply to Ondrej Bilka from comment #1)
> This problem cannot be solved without introducing new API.
> 
> Problem here is lack of function that removes fork handler.

The removal of the handlers could be done automatically when the DSO is
unloaded.

Each dso has a unique __dso_handle inserted by the compiler which is used when
registering the handlers via pthread_atfork.

When the DSO is unloaded we could look through the registered handlers and
remove those that belong to the DSO being unloaded.

The only other robust alternatives are:

* mark the DSOs as unloadable e.g. -z nodelete.

* don't use pthread_atfork

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libc/13502] SEGFAULT in fork() when pthread_atfork() was called from a library loaded/unloaded with dlopen/dlclose
  2011-12-15 12:17 [Bug libc/13502] New: SEGFAULT in fork() when pthread_atfork() was called from a library loaded/unloaded with dlopen/dlclose olma_ru at yahoo dot com
                   ` (4 preceding siblings ...)
  2013-10-03  1:17 ` carlos at redhat dot com
@ 2014-06-27 11:31 ` fweimer at redhat dot com
  5 siblings, 0 replies; 7+ messages in thread
From: fweimer at redhat dot com @ 2014-06-27 11:31 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=13502

Florian Weimer <fweimer at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |fweimer at redhat dot com
              Flags|                            |security-

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-06-27 11:31 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-15 12:17 [Bug libc/13502] New: SEGFAULT in fork() when pthread_atfork() was called from a library loaded/unloaded with dlopen/dlclose olma_ru at yahoo dot com
2011-12-15 12:18 ` [Bug libc/13502] " olma_ru at yahoo dot com
2012-12-19 10:46 ` schwab@linux-m68k.org
2013-09-21 20:21 ` neleai at seznam dot cz
2013-09-22  5:22 ` bugdal at aerifal dot cx
2013-10-03  1:17 ` carlos at redhat dot com
2014-06-27 11:31 ` fweimer at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).