Bug 88219

Summary: pthread_detach fails if thread has already exited
Product: [Retired] Red Hat Linux Reporter: Benjamin S. Scarlet <scarlet>
Component: glibcAssignee: Jakub Jelinek <jakub>
Status: CLOSED ERRATA QA Contact: Brian Brock <bbrock>
Severity: high Docs Contact:
Priority: medium    
Version: 9CC: fweimer
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2003-04-09 19:21:40 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Benjamin S. Scarlet 2003-04-07 19:46:18 UTC
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):

How reproducible:
Every time.

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

begin 644 threadtest.c.gz

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 19:21:40 UTC
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.