[PATCH] D14745: [tsan] Implement basic GCD interceptors for OS X

Kuba Brecka via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 17 05:13:24 PST 2015


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

We need to intercept libdispatch APIs (dispatch_sync, dispatch_async, etc.) to add synchronization between the code that submits the task and the code that gets executed (possibly on a different thread).

This code adds release+acquire semantics for dispatch_sync, dispatch_async, dispatch_after and dispatch_apply (plus their "_f" variants).  Added a simple testcase using dispatch_async, I'll add more GCD tests later.

For a program using libdispatch, TSan produces a bunch of false positives (from libxpc, libobjc, etc.).  In order to suppress those, I added a few system libraries into a list of default suppressions.

Secondly, dispatch_once is not properly interceptible, because part of it is inlined, see the comment in the patch.  To avoid false positives here, this patch ignores all reads and writes coming from the initializer within dispatch_once.


http://reviews.llvm.org/D14745

Files:
  lib/tsan/CMakeLists.txt
  lib/tsan/rtl/tsan_interceptors.cc
  lib/tsan/rtl/tsan_interceptors.h
  lib/tsan/rtl/tsan_libdispatch_mac.cc
  lib/tsan/rtl/tsan_suppressions.cc
  test/tsan/Darwin/gcd-simple.mm

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14745.40387.patch
Type: text/x-patch
Size: 11629 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151117/7a08ad11/attachment.bin>


More information about the llvm-commits mailing list