mailing list of musl libc
 help / color / mirror / code / Atom feed
* Duplicate call to pthread_join segvs
@ 2016-08-18 11:51 Steve Osselton
  2016-08-18 12:47 ` Rich Felker
  0 siblings, 1 reply; 2+ messages in thread
From: Steve Osselton @ 2016-08-18 11:51 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 429 bytes --]

Hi,

Am using musl on the latest Alpine Linux release. Although the behaviour of
calling pthread_join on
the same thread is undefined, would be nice if returned an errno as opposed
to a segv:

#include <pthread.h>

void * start_routine (void * arg)
{
}

int main (int argc, char ** argv)
{
  pthread_t id;

  pthread_create (&id, NULL, start_routine, NULL);
  pthread_join (id, NULL);
  pthread_join (id, NULL);
}

Cheers Steve.

[-- Attachment #2: Type: text/html, Size: 701 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Duplicate call to pthread_join segvs
  2016-08-18 11:51 Duplicate call to pthread_join segvs Steve Osselton
@ 2016-08-18 12:47 ` Rich Felker
  0 siblings, 0 replies; 2+ messages in thread
From: Rich Felker @ 2016-08-18 12:47 UTC (permalink / raw)
  To: musl

On Thu, Aug 18, 2016 at 12:51:23PM +0100, Steve Osselton wrote:
> Hi,
> 
> Am using musl on the latest Alpine Linux release. Although the behaviour of
> calling pthread_join on
> the same thread is undefined, would be nice if returned an errno as opposed
> to a segv:

No, that would be harmful because it would hide an extremely serious
bug (think what happens if another thread had been created after the
first join and its id happened to match the id of the already-joined
one). It would also be generally impossible to produce. pthread_join
is inherently a free-type operation (it frees a resource) and
double-frees are not reliably detectable unless the implementation
just never reuses freed resources at all (i.e. leak them).

Rich


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-08-18 12:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-18 11:51 Duplicate call to pthread_join segvs Steve Osselton
2016-08-18 12:47 ` Rich Felker

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).