Openwall GNU/*/Linux - a small security-enhanced Linux distro for servers
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue, 27 Mar 2018 14:32:55 +0200
From: Jens Gustedt <jens.gustedt@...ia.fr>
To: <Salman.Ahmed@...dmueller.com>
Cc: musl@...ts.openwall.com
Subject: Re: segmentation fault on pthread_detach

Hello Salman,

On Tue, 27 Mar 2018 12:00:39 +0000 <Salman.Ahmed@...dmueller.com> wrote:

> My application using musl libc runs into a seg fault if I call
> pthread_detach after pthread_join on the same thread. From my
> understanding pthread_detach should return ESRCH if a previous join
> was called on a particular thread. That’s the correct behavior I see
> if I run my program with glibc. But on my LEDE based router I run
> into the seg fault issue. The cross compiling toolchain I use is
> arm_cortex-a9+neon_gcc-5.4.0_musl-1.1.16_eabi. Simple example I used
> for testing is below.

I don't think that your expectation is correct. The POSIX standard
states:

> The behavior is undefined if the value specified by the thread argument
> to pthread_detach() does not refer to a joinable thread.

(a thread that has already been joined is not joinable)

This is for good reasons. The system must be able to dispose of all
resources that a thread occupied after it has been joined. The memory
will be reused, in particular there may be a new thread that uses the
same identifier.

Jens

-- 
:: INRIA Nancy Grand Est ::: Camus ::::::: ICube/ICPS :::
:: ::::::::::::::: office Strasbourg : +33 368854536   ::
:: :::::::::::::::::::::: gsm France : +33 651400183   ::
:: ::::::::::::::: gsm international : +49 15737185122 ::
:: http://icube-icps.unistra.fr/index.php/Jens_Gustedt ::

Content of type "application/pgp-signature" skipped

Powered by blists - more mailing lists

Your e-mail address:

Powered by Openwall GNU/*/Linux - Powered by OpenVZ