mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: [PATCH] thread: do not attempt to join detached threads in pthread_join()
Date: Tue, 1 Aug 2017 18:56:02 -0400	[thread overview]
Message-ID: <20170801225602.GE1627@brightrain.aerifal.cx> (raw)
In-Reply-To: <20170801224613.9732-1-nenolod@dereferenced.org>

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.

Rich


  reply	other threads:[~2017-08-01 22:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-01 22:46 William Pitcock
2017-08-01 22:56 ` Rich Felker [this message]
2017-08-01 23:12 William Pitcock

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170801225602.GE1627@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).