From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/5719 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general 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 Message-ID: <20140805170942.GG1674@brightrain.aerifal.cx> References: <1407257494.24324.241.camel@eris.loria.fr> 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 1407258601 25261 80.91.229.3 (5 Aug 2014 17:10:01 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 5 Aug 2014 17:10:01 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-5724-gllmg-musl=m.gmane.org@lists.openwall.com Tue Aug 05 19:09:57 2014 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1XEiFI-0001Ql-2i for gllmg-musl@plane.gmane.org; Tue, 05 Aug 2014 19:09:56 +0200 Original-Received: (qmail 17786 invoked by uid 550); 5 Aug 2014 17:09:55 -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 17776 invoked from network); 5 Aug 2014 17:09:54 -0000 Content-Disposition: inline In-Reply-To: <1407257494.24324.241.camel@eris.loria.fr> User-Agent: Mutt/1.5.21 (2010-09-15) Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:5719 Archived-At: 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