From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: trouble spots for atomic access
Date: Wed, 20 May 2015 10:56:42 -0400 [thread overview]
Message-ID: <20150520145642.GX17573@brightrain.aerifal.cx> (raw)
In-Reply-To: <20150520110518.GG11258@port70.net>
On Wed, May 20, 2015 at 01:05:19PM +0200, Szabolcs Nagy wrote:
> * Jens Gustedt <jens.gustedt@inria.fr> [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
This sounds promising, but I'm still a bit worried about making the
change. I wonder if there's other data that could support the safety
of doing it.
Rich
prev parent reply other threads:[~2015-05-20 14:56 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-19 13:57 Jens Gustedt
2015-05-19 22:07 ` Rich Felker
2015-05-19 22:47 ` Jens Gustedt
2015-05-19 23:15 ` Rich Felker
2015-05-20 7:02 ` Jens Gustedt
2015-05-20 14:55 ` Rich Felker
2015-05-20 11:05 ` Szabolcs Nagy
2015-05-20 14:56 ` Rich Felker [this message]
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=20150520145642.GX17573@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).