mailing list of musl libc
 help / color / mirror / code / Atom feed
* trouble spots for atomic access
@ 2015-05-19 13:57 Jens Gustedt
  2015-05-19 22:07 ` Rich Felker
  0 siblings, 1 reply; 8+ messages in thread
From: Jens Gustedt @ 2015-05-19 13:57 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 1542 bytes --]

Hello,
by forcing the compiler to detect consistency checks for 
atomics as I mentioned earlier, I detected 5 trouble spots. The first
four are relatively clear:

 - a_and and a_or interfaces on i386 and friends are not consistent
   with the remaining archs. They have `volatile void*` for the
   arguments and then do a gratuitous cast to `int*`. As far as I can
   see just using `volatile int*` as for the other archs works fine.
 - pthread_once_t should always be volatile
 - pthread_spinlock_t should always be volatile
 - pthread_barrier needs atomic increment

The fifth troubles me a bit. It concerns __timedwait and
__timedwait_cp. These both are mostly used with a first argument addr
that is atomic. This makes sense, since addr then is passed to a call
to futex, which internally might do some atomic operations. Now there
is one call that doesn't pass something that is otherwise seen as
atomic, namely line 14 in pthread_join.c. It reads as

	while ((tmp = t->tid)) __timedwait_cp(&t->tid, tmp, 0, 0, 0);

So is the task id here to be seen as atomic, or not? Will updates to
that field that are not atomic (and maybe optimized in some sort) be
able to mess up the futex call?

Thanks
Jens

-- 
:: INRIA Nancy Grand Est ::: Camus ::::::: ICube/ICPS :::
:: ::::::::::::::: office Strasbourg : +33 368854536   ::
:: :::::::::::::::::::::: gsm France : +33 651400183   ::
:: ::::::::::::::: gsm international : +49 15737185122 ::
:: http://icube-icps.unistra.fr/index.php/Jens_Gustedt ::





[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-05-20 14:56 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-19 13:57 trouble spots for atomic access 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

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).