diff options
| author | Kuba Brecka <kuba.brecka@gmail.com> | 2016-09-04 09:55:12 +0000 |
|---|---|---|
| committer | Kuba Brecka <kuba.brecka@gmail.com> | 2016-09-04 09:55:12 +0000 |
| commit | 224264ade0674f8ce120432614abfd880323f105 (patch) | |
| tree | 3f61523a69c3dab582196d1c5a887ee392262a95 /libcxx/include/mutex | |
| parent | ccd44939ef93dae2822fbfc6ff6eb3d2376ad2f2 (diff) | |
| download | bcm5719-llvm-224264ade0674f8ce120432614abfd880323f105.tar.gz bcm5719-llvm-224264ade0674f8ce120432614abfd880323f105.zip | |
[libcxx] Fix a data race in call_once
call_once is using relaxed atomic load to perform double-checked locking, which contains a data race. The fast-path load has to be an acquire atomic load.
Differential Revision: https://reviews.llvm.org/D24028
llvm-svn: 280621
Diffstat (limited to 'libcxx/include/mutex')
| -rw-r--r-- | libcxx/include/mutex | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/libcxx/include/mutex b/libcxx/include/mutex index c047cf943e8..79befbeb56f 100644 --- a/libcxx/include/mutex +++ b/libcxx/include/mutex @@ -574,7 +574,7 @@ inline _LIBCPP_INLINE_VISIBILITY void call_once(once_flag& __flag, _Callable&& __func, _Args&&... __args) { - if (__libcpp_relaxed_load(&__flag.__state_) != ~0ul) + if (__libcpp_acquire_load(&__flag.__state_) != ~0ul) { typedef tuple<_Callable&&, _Args&&...> _Gp; _Gp __f(_VSTD::forward<_Callable>(__func), _VSTD::forward<_Args>(__args)...); @@ -590,7 +590,7 @@ inline _LIBCPP_INLINE_VISIBILITY void call_once(once_flag& __flag, _Callable& __func) { - if (__libcpp_relaxed_load(&__flag.__state_) != ~0ul) + if (__libcpp_acquire_load(&__flag.__state_) != ~0ul) { __call_once_param<_Callable> __p(__func); __call_once(__flag.__state_, &__p, &__call_once_proxy<_Callable>); |

