Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20140805170942.GG1674@brightrain.aerifal.cx>
Date: Tue, 5 Aug 2014 13:09:43 -0400
From: Rich Felker <dalias@...c.org>
To: musl@...ts.openwall.com
Subject: Re: PATCH: don't call cleanup handlers after a regular return
 from the thread start function

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

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.