This service will be undergoing maintenance at 00:00 UTC, 2016-09-28. It is expected to last about 1 hours
Bug 88219 - pthread_detach fails if thread has already exited
pthread_detach fails if thread has already exited
Status: CLOSED ERRATA
Product: Red Hat Linux
Classification: Retired
Component: glibc (Show other bugs)
9
i386 Linux
medium Severity high
: ---
: ---
Assigned To: Jakub Jelinek
Brian Brock
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2003-04-07 15:46 EDT by Benjamin S. Scarlet
Modified: 2007-04-18 12:52 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2003-04-09 15:21:40 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)

  None (edit)
Description Benjamin S. Scarlet 2003-04-07 15:46:18 EDT
Description of problem:
The behaviour of pthread_detach has changed from previous versions, and seems
wrong. (Without the posix standard, which I don't have, I can't say for
certain). If the thread being detached has already exited, then pthread_detach
fails with ESRCH, where it used to succeed (and succeeds on Solaris). 

Version-Release number of selected component (if applicable):
glibc-2.3.2-11.9

How reproducible:
Every time.

Steps to Reproduce:
uudecode, gunzip, compile, and run the following code

begin 644 threadtest.c.gz
M'XL("(W3D3X``W1H<F5A9'1E<W0N8P"%4DUOPC`,O?=7>""F!'43VY&._0*T
MVVZ34-2F-%))D..B21/_?4X3"F43Y!`YSQ_OV?'4V++M*@UO>VI0J^JY><^F
M`]A9X^D*8\"X`&4'9RJ8U\Z):"G<2OC)@,\>C:5:3-@)GA32EYW(HG?Y5NN]
M>$FOR\#*67V.0TT=6OCX7*^+[)C8:F5:P1F@$1WF4#KK"<I&(<QW?J"O4UG6
MRH$Y3$)>AWHY\\M9Q3?3Y,`)^:F0)^PMT=\R:=#?AL13T,H"`NU.&=OS<Z]E
MGHA#XX>A\SC'C2+"#8V>Q2A@\$4X%$7MNY:*+`(UB`C`:ES56%;U>`E)>%C!
MXB2AGT`85$SG]O^DG\=\O,%6\DU:#$7#.?'F_Z(]P]C%/SL&PH^.`)F-K7M=
F1%E7#<2U>I6WIE=I4F4CTE/>GU=,N&)*B[D(2_$+01;,?D`#````
`
end

   
Actual results:
$ cc     threadtest.c  -lpthread -o threadtest
$ ./threadtest
foo start
foo done
failure:pthread_detach:3:No such process

Expected results:
$ cc     threadtest.c  -lpthread -o threadtest
$ ./threadtest
foo start
foo done

Additional info:
A cursory look at the code from the nptl in the glibc source RPM suggests that
the tid field in the pthread structure is set to zero when the thread
exits, and pthread_detach doesn't handle that situation. (Joining the thread
after it exits works fine, and pthread_join uses a different test which differs
only by the tid==0 case).
Comment 1 Jakub Jelinek 2003-04-09 15:21:40 EDT
An errata has been issued which should help the problem described in this bug report. 
This report is therefore being closed with a resolution of ERRATA. For more information
on the solution and/or where to find the updated files, please follow the link below. You may reopen 
this bug report if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2003-136.html

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