diff options
author | rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-11-28 21:01:26 +0000 |
---|---|---|
committer | rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-11-28 21:01:26 +0000 |
commit | f0b6dfa6477590110bf9bd18d6c3cfa2e66420fe (patch) | |
tree | f08c3d71c7d0d279f944d16c9cc812bbd7a2220a /libgcc | |
parent | 80d4c05f76e0073a56d14287151cb29929a7ba63 (diff) | |
download | gcc-f0b6dfa6477590110bf9bd18d6c3cfa2e66420fe.tar.gz |
PR libgcc/48076
* emutls.c (__emutls_get_address): Avoid race condition between
obj->loc.offset read and emutls_key initialization.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@193907 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgcc')
-rw-r--r-- | libgcc/ChangeLog | 6 | ||||
-rw-r--r-- | libgcc/emutls.c | 4 |
2 files changed, 8 insertions, 2 deletions
diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog index c547dcb06c6..6506e85e89f 100644 --- a/libgcc/ChangeLog +++ b/libgcc/ChangeLog @@ -1,3 +1,9 @@ +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> Adjust decimal point of signed accum mode to GCC default. diff --git a/libgcc/emutls.c b/libgcc/emutls.c index 22ea4403edb..f1b653b7d54 100644 --- a/libgcc/emutls.c +++ b/libgcc/emutls.c @@ -136,7 +136,7 @@ __emutls_get_address (struct __emutls_object *obj) #ifndef __GTHREADS abort (); #else - pointer offset = obj->loc.offset; + pointer offset = __atomic_load_n (&obj->loc.offset, __ATOMIC_ACQUIRE); if (__builtin_expect (offset == 0, 0)) { @@ -147,7 +147,7 @@ __emutls_get_address (struct __emutls_object *obj) if (offset == 0) { offset = ++emutls_size; - obj->loc.offset = offset; + __atomic_store_n (&obj->loc.offset, offset, __ATOMIC_RELEASE); } __gthread_mutex_unlock (&emutls_mutex); } |