From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/7717 Path: news.gmane.org!not-for-mail From: Szabolcs Nagy Newsgroups: gmane.linux.lib.musl.general Subject: Re: trouble spots for atomic access Date: Wed, 20 May 2015 13:05:19 +0200 Message-ID: <20150520110518.GG11258@port70.net> References: <1432043820.27572.26.camel@inria.fr> <20150519220722.GO17573@brightrain.aerifal.cx> <1432075664.22607.12.camel@inria.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 1432119945 3678 80.91.229.3 (20 May 2015 11:05:45 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 20 May 2015 11:05:45 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-7729-gllmg-musl=m.gmane.org@lists.openwall.com Wed May 20 13:05:33 2015 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1Yv1oa-0001tC-LC for gllmg-musl@m.gmane.org; Wed, 20 May 2015 13:05:32 +0200 Original-Received: (qmail 3966 invoked by uid 550); 20 May 2015 11:05:31 -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 3947 invoked from network); 20 May 2015 11:05:30 -0000 Mail-Followup-To: musl@lists.openwall.com Content-Disposition: inline In-Reply-To: <1432075664.22607.12.camel@inria.fr> User-Agent: Mutt/1.5.23 (2014-03-12) Xref: news.gmane.org gmane.linux.lib.musl.general:7717 Archived-At: * Jens Gustedt [2015-05-20 00:47:44 +0200]: > Am Dienstag, den 19.05.2015, 18:07 -0400 schrieb Rich Felker: > > On Tue, May 19, 2015 at 03:57:00PM +0200, Jens Gustedt wrote: > > > - pthread_once_t should always be volatile > > > - pthread_spinlock_t should always be volatile > > > > These are C++ ABI changes. I'd like to make the change but I'm > > concerned it might break things. > > Both are broken as they are now, if you fall into a compiler that > "knows" that the object itself isn't volatile qualified, and by that > excuse takes the liberty to optimize out loads. For both types there > is one point where there is a cast to (volatile int*) followed by a > load, that might not do what we want. > > (For pthread_once_t, this on line 43 in pthread_once.c) > > I think the safest would be to make the data types volatile. If that > is not possible, do the load with some new function "a_load_rel" that > is guaranteed to be volatile, atomic and with memory_order relaxed. > fwiw i scanned a significant portion of debian packages with nm -CD for volatile int* usage and didnt find any case that was related to posix types (a few libraries dealing with atomics had their own volatile int*) (found 6553 packages with c++ dependencies in stable, scanned them all) so changing the types wouldnt break too many musl binaries i think