Re: [PATCH] D21816: [tsan] Stop extending the block’s lifetime in dispatch_group_async
Kuba Brecka via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 29 02:31:41 PDT 2016
kubabrecka added inline comments.
================
Comment at: lib/tsan/rtl/tsan_libdispatch_mac.cc:289
@@ -288,1 +288,3 @@
+ block_copy();
+ _Block_release(block_copy);
WRAP(dispatch_group_leave)(group);
----------------
dvyukov wrote:
> What does keep the block alive currently? When is it destroyed without this change?
Without this change, the block named "block" is captured by this anonymous block that's submitted via dispatch_async, and it's also released only when this anonymous block is released (after dispatch completely executes it). That means the release only happens after the two lines below (call to dispatch_group_leave and dispatch_release).
With this change, we're avoiding the capture (with __block) by explicitly copying the block. It will be released/destroyed at the call to _Block_release (as long as there are no other references to the block).
================
Comment at: test/tsan/Darwin/gcd-groups-destructor.mm:43
@@ +42,2 @@
+// CHECK: Done.
+// CHECK-NOT: WARNING: ThreadSanitizer
----------------
dvyukov wrote:
> AFAIK, filecheck checks line-by-line, so this ensures that there are no WARNINGS _after_ "Done." is printed. I think you need to move CHECK_NOT before Done CHECK.
Ok
http://reviews.llvm.org/D21816
More information about the llvm-commits
mailing list