From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/8527 Path: news.gmane.org!not-for-mail From: Szabolcs Nagy Newsgroups: gmane.linux.lib.musl.general Subject: Re: pthread_join stuck in infinite loop Date: Sun, 20 Sep 2015 20:29:36 +0200 Message-ID: <20150920182936.GC10551@port70.net> References: Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1442773803 7793 80.91.229.3 (20 Sep 2015 18:30:03 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 20 Sep 2015 18:30:03 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-8539-gllmg-musl=m.gmane.org@lists.openwall.com Sun Sep 20 20:29:51 2015 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1ZdjN0-0004DQ-Hv for gllmg-musl@m.gmane.org; Sun, 20 Sep 2015 20:29:50 +0200 Original-Received: (qmail 23649 invoked by uid 550); 20 Sep 2015 18:29:49 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 23627 invoked from network); 20 Sep 2015 18:29:48 -0000 Mail-Followup-To: musl@lists.openwall.com Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Xref: news.gmane.org gmane.linux.lib.musl.general:8527 Archived-At: * Julien Ramseier [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.