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: don't call cleanup handlers after a regular return from the thread start function
Date: Tue, 5 Aug 2014 13:09:43 -0400	[thread overview]
Message-ID: <20140805170942.GG1674@brightrain.aerifal.cx> (raw)
In-Reply-To: <1407257494.24324.241.camel@eris.loria.fr>

On Tue, Aug 05, 2014 at 06:51:34PM +0200, Jens Gustedt wrote:
> Don't call cleanup handlers after a regular return from the thread
> start function
> 
> The chained list of cleanup handler function uses list items that are
> local to the respective function of a cleanup block. In case of a
> return out of the middle of a cleanup block, using these list items
> can lead to UB.
> 
> POSIX lists three different cases in which a cleanup handler that is
> established on the cleanup stack has to be executed. Regular return
> from the thread start function is not among these cases.
> 
> Linux manpages are more explicit and state:
> 
>     Clean-up handlers are not called if the thread terminates by
>     performing a return from the thread start function.
> 
> This patch aligns musl to that behavior.

Could you clarify why this patch is necessary? I think such a return
is explicitly UB:

"The effect of the use of return, break, continue, and goto to
prematurely leave a code block described by a pair of
pthread_cleanup_push() and pthread_cleanup_pop() functions calls is
undefined."

http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_cleanup_pop.html

I don't see why the thread start function should be treated as special
here.

Rich


  reply	other threads:[~2014-08-05 17:09 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-05 16:51 Jens Gustedt
2014-08-05 17:09 ` Rich Felker [this message]
2014-08-05 19:06   ` Jens Gustedt
2014-08-05 19:41     ` Rich Felker
2014-08-05 20:29       ` Rich Felker
2014-08-05 21:05       ` Jens Gustedt
2014-08-05 21:48         ` Rich Felker
2014-08-05 23:19           ` Jens Gustedt
2014-08-06  2:02             ` Rich Felker
2014-08-06  7:15               ` Jens Gustedt
2014-08-06  9:35                 ` Rich Felker
2014-08-06 10:00                   ` Jens Gustedt
2014-08-06 10:12                     ` 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=20140805170942.GG1674@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).