mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Szabolcs Nagy <nsz@port70.net>
To: musl@lists.openwall.com
Subject: Re: pthread_join stuck in infinite loop
Date: Sun, 20 Sep 2015 20:29:36 +0200	[thread overview]
Message-ID: <20150920182936.GC10551@port70.net> (raw)
In-Reply-To: <B9275837-6376-4749-8179-E203DC48E230@gmail.com>

* Julien Ramseier <j.ramseier@gmail.com> [2015-09-20 20:07:28 +0200]:
> pthread_join() never returns when calling it on a detached thread.
> I would expect it to return EINVAL instead.
> 

"If a thread is detached, its thread ID is invalid for use as an
 argument in a call to pthread_detach() or pthread_join()."
http://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_09_02

"The behavior is undefined if the value specified by the thread
 argument to pthread_join() does not refer to a joinable thread."
http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_join.html

unfortunately historically ppl believed that detecting detached
state is possible so the rationale for pthread_join still has

"If an implementation detects that the value specified by the
 thread argument to pthread_join() does not refer to a joinable
 thread, it is recommended that the function should fail and
 report an [EINVAL] error."

in particular the glibc man page says EINVAL is correctly
reported in all cases which i dont think is true: there
is a race between the detached thread exiting an join.



  reply	other threads:[~2015-09-20 18:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-20 18:07 Julien Ramseier
2015-09-20 18:29 ` Szabolcs Nagy [this message]
2015-09-20 18:41   ` Jens Gustedt
2015-09-21  9:00     ` Julien Ramseier
2015-09-20 18:33 ` Rich Felker

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=20150920182936.GC10551@port70.net \
    --to=nsz@port70.net \
    --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).