Bug 74437 - Calling fork() from a pthread randomly nukes some of the other threads
Summary: Calling fork() from a pthread randomly nukes some of the other threads
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Enterprise Linux 2.1
Classification: Red Hat
Component: glibc
Version: 2.1
Hardware: All
OS: Linux
medium
high
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Brian Brock
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2002-09-24 12:02 UTC by Johan Walles
Modified: 2016-11-24 14:59 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2002-09-26 07:41:09 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
Test program, build with gcc -lpthreads (1.62 KB, text/plain)
2002-09-24 12:03 UTC, Johan Walles
no flags Details

Description Johan Walles 2002-09-24 12:02:31 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.0) Gecko/20020607

Description of problem:
The attached program creates ten threads that waste cycles for three secs, then
finish.  An eleventh thread waits half a sec and then does a fork()/exec(). 
Some of the times (one in ten?) I run this program, most of the threads get
killed off before finishing.  I have tried this on RHAS2.1 on both IA32 and IA64
and get similar results on both platforms.

Version-Release number of selected component (if applicable):
2.2.4-26 (on IA32) and 2.2.4-27.2 on (IA64)

How reproducible:
Sometimes

Steps to Reproduce:
1. Build the attached program (passing -lpthreads to gcc).
2. Run it.


Actual Results:  Some of the threads get killed off before finishing.


Expected Results:  All threads should report they have finished.


Additional info:

Comment 1 Johan Walles 2002-09-24 12:03:41 UTC
Created attachment 77009 [details]
Test program, build with gcc -lpthreads

Comment 2 Johan Walles 2002-09-25 15:13:09 UTC
Actually, I just discovered that the exec() doesn't have anything to do with
this.  If you do exit(0) the first thing you do in the child, you still get the
same behaviour :-(.  Tested on RHAS/ia32 and RHAS/ia64.

This (obviously) makes it impossible to (reliably) do fork()/exec() from any
threaded app.


Comment 3 Johan Walles 2002-09-26 07:41:03 UTC
For what it's worth, I am unable to reproduce the problematic behaviour inside
GDB.  As GDB and pthreads are rather entangled this is not entirely surprizing.


Comment 4 Johan Walles 2002-09-26 08:08:04 UTC
Regardless of fork() or not, all threads are terminated when the main thread
terminates.  Since the main thread was performing the same time-wasting
operation as all the others, there was a race giving different behaviour
depending on how the threads got scheduled.

You learn something new every day :-).



Note You need to log in before you can comment on or make changes to this bug.