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=38682
rdar://problem/42548261
Differential D51170
[libc++] Remove race condition in std::async ldionne on Aug 23 2018, 9:20 AM. Authored by
Details The state associated to the future was set in one thread (with synchronization) https://bugs.llvm.org/show_bug.cgi?id=38682
Diff Detail
Event Timeline
|
I'm not auditing everything, but it seems like code above can still access state_ without holding mut_? Like in the dtor.
Generally this patch lgtm because it's a step forward, but maybe we should separately refactor the code to make it so that accesses to state_ require passing in a reference to lock_guard to show we actually hold mut_. It would ignore that reference, but that's a way to enforce, in the type system, that __state_ is only touched when the lock is held.
WDYT?