diff options
| author | Louis Dionne <ldionne@apple.com> | 2018-08-24 14:00:59 +0000 |
|---|---|---|
| committer | Louis Dionne <ldionne@apple.com> | 2018-08-24 14:00:59 +0000 |
| commit | 616ef1863faef8dedf2e6bfbaee7569d84f11e35 (patch) | |
| tree | 1605d2b26c8b01156a179ee6f223643b5b89eeba /libcxx/src | |
| parent | 689bf93b2ff10ee1d94249274353bb819618a16d (diff) | |
| download | bcm5719-llvm-616ef1863faef8dedf2e6bfbaee7569d84f11e35.tar.gz bcm5719-llvm-616ef1863faef8dedf2e6bfbaee7569d84f11e35.zip | |
[libc++] Remove race condition in std::async
Summary:
The state associated to the future was set in one thread (with synchronization)
but read in another thread without synchronization, which led to a data race.
https://bugs.llvm.org/show_bug.cgi?id=38181
rdar://problem/42548261
Reviewers: mclow.lists, EricWF
Subscribers: christof, dexonsmith, cfe-commits
Differential Revision: https://reviews.llvm.org/D51170
llvm-svn: 340608
Diffstat (limited to 'libcxx/src')
| -rw-r--r-- | libcxx/src/future.cpp | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/libcxx/src/future.cpp b/libcxx/src/future.cpp index 07e4602f567..cbcd2e7b728 100644 --- a/libcxx/src/future.cpp +++ b/libcxx/src/future.cpp @@ -179,10 +179,7 @@ __assoc_sub_state::__execute() future<void>::future(__assoc_sub_state* __state) : __state_(__state) { - if (__state_->__has_future_attached()) - __throw_future_error(future_errc::future_already_retrieved); - __state_->__add_shared(); - __state_->__set_future_attached(); + __state_->__attach_future(); } future<void>::~future() |

