[PATCH] D51170: [libc++] Remove race condition in std::async

JF Bastien via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 23 16:27:08 PDT 2018


jfb accepted this revision.
jfb added inline comments.
This revision is now accepted and ready to land.


================
Comment at: libcxx/include/future:556
     bool __has_value() const
         {return (__state_ & __constructed) || (__exception_ != nullptr);}
 
----------------
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?


Repository:
  rCXX libc++

https://reviews.llvm.org/D51170





More information about the cfe-commits mailing list