This is the mail archive of the
glibc-bugs@sources.redhat.com
mailing list for the glibc project.
[Bug nptl/914] New: pthread_atfork hangs thread after fork
- From: "mkwasigr at intercope dot com" <sourceware-bugzilla at sources dot redhat dot com>
- To: glibc-bugs at sources dot redhat dot com
- Date: 2 May 2005 12:30:12 -0000
- Subject: [Bug nptl/914] New: pthread_atfork hangs thread after fork
- Reply-to: sourceware-bugzilla at sources dot redhat dot com
Hi all,
I have come up with a test case where to "reliably" hang threads that use
pthread_atfork() to guarantee that a pthread_mutex semaphore is unlocked in the
parent and the child process after a fork(). I will attch the test case to this
bug report if possible, please email me if I can't...
BTW, the same test program cause SEGVs in LinuxThreads ... (I'll file a separate
bug report against LinuxThreads based on the outcome of this one if necessary).
All this has been tested on a dual P4 3GHz PC running Red Hat Advanced Server 4
with GLIBC 2.3.4 compiled by GCC 3.4.3 but exactly the same symptoms have been
observed on uniprocessor machines and previous GLIBC versions with NPTL.
It is reproducible on every attempt.
My test case basically does the following:
1. It has a global pthread_mutex to serialize a critical section.
2. main() establishes signal handler for SIGCHLD to reap all unwaited
children and for SIGINT to gracefully shut down on CTRL-C
3. main() establishes a fork handler to
(a) lock the mutex before the fork and to
(b) unlock the mutex in the parent and the child after the fork.
4. main() starts a thread that in a loop
(a) forks and in the child execs '/bin/sleep 10' and
(b) sleeps for 1 second in the parent
until CTRL-C is pressed.
The expected behaviour is that there is a message from main and a message from
the thread for every second. However, with the atfork handler, there are several
message from main() but only one message from the thread but main() runs until
it is stopped.
NB: joining the thread appears to be possible, even if it is hung up.
Without the atfork handler, main() and the thread are running nicely side by side.
Thanks and best regards,
- Michael Kwasigroch
--
Summary: pthread_atfork hangs thread after fork
Product: glibc
Version: unspecified
Status: NEW
Severity: normal
Priority: P2
Component: nptl
AssignedTo: drepper at redhat dot com
ReportedBy: mkwasigr at intercope dot com
CC: glibc-bugs at sources dot redhat dot com
http://sources.redhat.com/bugzilla/show_bug.cgi?id=914
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.