This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug nptl/22337] pthread_join incorrectly fails for a detached running thread
- From: "carlos at redhat dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sourceware dot org
- Date: Mon, 23 Oct 2017 21:33:00 +0000
- Subject: [Bug nptl/22337] pthread_join incorrectly fails for a detached running thread
- Auto-submitted: auto-generated
- References: <bug-22337-131@http.sourceware.org/bugzilla/>
https://sourceware.org/bugzilla/show_bug.cgi?id=22337
Carlos O'Donell <carlos at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |carlos at redhat dot com
--- Comment #8 from Carlos O'Donell <carlos at redhat dot com> ---
(In reply to Andreas Schwab from comment #7)
> It says that pthread_detach has the same effect as PTHREAD_CREATE_DETACHED.
I agree with Andreas, it is the principle of least surprise.
Once you call pthread_detach() it *should* behave as if you'd started the
thread with PTHREAD_CREATE_DETACHED.
This means pthread_join returns EINVAL (thread is not joinable) as soon as
pthread_detach finishes setting joinid to itself.
The other thing to consider is this: What happens if you call pthread_detach()
*while* another thread is already waiting? (this is mentioned in the comments
in pthread_detach).
I think the only bug is that a pthread_join *before* a pthread_detach should
result in pthread_detach returning EINVAL, but right now it looks like we
return 0 (just looking at the code, would need a test case for this).
--
You are receiving this mail because:
You are on the CC list for the bug.