Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Tue, 1 Aug 2017 18:56:02 -0400
From: Rich Felker <>
Subject: Re: [PATCH] thread: do not attempt to join detached threads
 in pthread_join()

On Tue, Aug 01, 2017 at 10:46:13PM +0000, William Pitcock wrote:
> A thread which is detached releases it's resources and TCB upon thread termination.
> Therefore a thread which is detached is not joinable as any underlying futex will not
> be incremented, resulting in a deadlock.  Accordingly, we return EINVAL instead of
> attempting to wait on a detached thread.
> Other pthread implementations such as glibc NPTL and FreeBSD also reject attempts
> to join detached threads with EINVAL.

Since the behavior is undefined and *can't be defined* in the general
case (where the detached thread may already have exited and its id may
even have been reused for a new thread), if any change is to be made,
the function should be made to crash in this case. Returning EINVAL
hides the (serious) programming error.


Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.