[PATCH] D15048: [tsan] Add dispatch_group API interceptors and synchronization
Kuba Brecka via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 7 05:50:46 PST 2015
kubabrecka added inline comments.
================
Comment at: lib/tsan/rtl/tsan_libdispatch_mac.cc:193
@@ +192,3 @@
+ WRAP(dispatch_async)(queue, ^(void) {
+ block();
+ WRAP(dispatch_group_leave)(group);
----------------
dvyukov wrote:
> Why don't we need Block_copy here, but need it below? Is the block automatically referenced from captured by another block?
Technically, we don't need Block_copy for correctness, because the function that will store a reference to a block for later (dispatch_async in this case) will do it anyway. The reason for a Block_copy here is to get rid of a very common false positive, because Block_copy will call malloc and the malloc'd region is then accessed from another thread. Since this happens *inside* dispatch_async, it's already after we've Release()'d. So I'm just forcing the allocation to happen early (before `Release()`).
I'm not calling Block_copy here, because `WRAP(dispatch_async)` will call it anyway. Below, we're calling `REAL(...)`, so we need to Block_copy.
http://reviews.llvm.org/D15048
More information about the llvm-commits
mailing list