Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 88219 - pthread_detach fails if thread has already exited
Summary: pthread_detach fails if thread has already exited
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: glibc
Version: 9
Hardware: i386
OS: Linux
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Brian Brock
Depends On:
TreeView+ depends on / blocked
Reported: 2003-04-07 19:46 UTC by Benjamin S. Scarlet
Modified: 2016-11-24 14:53 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2003-04-09 19:21:40 UTC

Attachments (Terms of Use)

System ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2003:136 high SHIPPED_LIVE glibc bugfix errata 2003-04-09 04:00:00 UTC

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.

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