[PATCH] D14328: [tsan] Handle libdispatch worker threads on OS X

Kuba Brecka via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 4 03:36:57 PST 2015


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

On OS X, GCD worker threads are created without a call to pthread_create. We need to properly register these threads with ThreadCreate and ThreadStart.  If we don't do that, the first interceptor called on such a thread will crash.

This patch uses a libpthread API (`pthread_introspection_hook_install`) to get notifications about new threads and about threads that are about to be destroyed.  The worker threads don't have a parent thread, as they are created "spuriously", so a few internal functions need to be modified to accept an invalid (kInvalidTid) parent thread ID.

(This is part of an effort to port TSan to OS X, and it's one the very first steps. Don't expect TSan on OS X to actually work or pass tests at this point.)


http://reviews.llvm.org/D14328

Files:
  lib/tsan/rtl/tsan_clock.cc
  lib/tsan/rtl/tsan_interceptors.cc
  lib/tsan/rtl/tsan_platform.h
  lib/tsan/rtl/tsan_platform_mac.cc
  lib/tsan/rtl/tsan_rtl.h
  lib/tsan/rtl/tsan_rtl_thread.cc

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14328.39181.patch
Type: text/x-patch
Size: 5654 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151104/2409c2a0/attachment.bin>


More information about the llvm-commits mailing list