Commit f4919e4a by Richard Henderson Committed by Richard Henderson

re PR libgcc/48076 (Unsafe double checked locking in __emutls_get_address)

PR libgcc/48076
        * emutls.c (__emutls_get_address): Avoid race condition between
        obj->loc.offset read and emutls_key initialization.

From-SVN: r193907
parent 361a58da
2012-11-28 Richard Henderson <rth@redhat.com>
PR libgcc/48076
* emutls.c (__emutls_get_address): Avoid race condition between
obj->loc.offset read and emutls_key initialization.
2012-11-22 Georg-Johann Lay <avr@gjlay.de> 2012-11-22 Georg-Johann Lay <avr@gjlay.de>
Adjust decimal point of signed accum mode to GCC default. Adjust decimal point of signed accum mode to GCC default.
......
...@@ -136,7 +136,7 @@ __emutls_get_address (struct __emutls_object *obj) ...@@ -136,7 +136,7 @@ __emutls_get_address (struct __emutls_object *obj)
#ifndef __GTHREADS #ifndef __GTHREADS
abort (); abort ();
#else #else
pointer offset = obj->loc.offset; pointer offset = __atomic_load_n (&obj->loc.offset, __ATOMIC_ACQUIRE);
if (__builtin_expect (offset == 0, 0)) if (__builtin_expect (offset == 0, 0))
{ {
...@@ -147,7 +147,7 @@ __emutls_get_address (struct __emutls_object *obj) ...@@ -147,7 +147,7 @@ __emutls_get_address (struct __emutls_object *obj)
if (offset == 0) if (offset == 0)
{ {
offset = ++emutls_size; offset = ++emutls_size;
obj->loc.offset = offset; __atomic_store_n (&obj->loc.offset, offset, __ATOMIC_RELEASE);
} }
__gthread_mutex_unlock (&emutls_mutex); __gthread_mutex_unlock (&emutls_mutex);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment