[PATCH] D18502: [tsan] Fix synchronization in dispatch_sync

Kuba Brecka via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 27 14:07:15 PDT 2016

kubabrecka created this revision.
kubabrecka added reviewers: dvyukov, glider, samsonov, kcc.
kubabrecka added subscribers: llvm-commits, zaks.anna, dcoughlin.

In the interceptor for dispatch_sync, we're currently missing synchronization between the callback and the code *after* the call to dispatch_sync.  So we'll false report a race in:

    // now executing on a background queue/thread
    dispatch_sync(main_queue, ^{ // "main_queue" forces the callback to be executed on a different thread
      x = 42;
    print(x); // back on the background_thread

This patch fixes this by adding an extra release+acquire pair to dispatch_sync() and similar APIs.  Added a testcase.



-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18502.51748.patch
Type: text/x-patch
Size: 9269 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160327/72de0b5c/attachment.bin>

More information about the llvm-commits mailing list