[PATCH] D21609: [tsan] Intercept libcxx __release_shared to avoid false positive with weak_ptrs and destructors in C++

Kuba Brecka via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 23 09:02:45 PDT 2016


kubabrecka added a comment.

In http://reviews.llvm.org/D21609#465611, @dvyukov wrote:

> Uh, if destructor is called there, then it won't work. Recursive mutexes won't help. A destructor can spawn another thread and wait for its completion, while the other thread can destroy other shared_ptr's which in turn will try to acquire the same mutex.


:(

Okay, another option:  Reimplementing the `__release_shared` method without calling REAL().  Either we could cast it to a carefully-crafted C++ class that’s set up in the same way as __shared_weak_count is, or we could do some extremely ugly pointer arithmetics & vtable magic.  But it should work, because the ABI is (and needs to be) stable.  Opinions?


http://reviews.llvm.org/D21609





More information about the llvm-commits mailing list