[PATCH] D14987: [tsan] Add interceptors for Darwin-specific locking APIs

Dmitry Vyukov via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 30 06:28:20 PST 2015


dvyukov added inline comments.

================
Comment at: lib/tsan/rtl/tsan_platform_mac.cc:190
@@ -186,1 +189,3 @@
 
+TSAN_INTERCEPTOR(void, OSSpinLockLock, volatile OSSpinLock *lock) {
+  if (!cur_thread()->is_inited) {
----------------
This all should go into tsan_interceptors_mac.cc.
tsan_platform_* is portability layer, not meant to contain any race-detection logic.
Also, tsan_platform_mac.cc is built in Go mode, but Go does not need any of these interceptors.



================
Comment at: lib/tsan/rtl/tsan_platform_mac.cc:191
@@ +190,3 @@
+TSAN_INTERCEPTOR(void, OSSpinLockLock, volatile OSSpinLock *lock) {
+  if (!cur_thread()->is_inited) {
+    return REAL(OSSpinLockLock)(lock);
----------------
I wonder whether this interceptors can come when thr->is_dead?
Add CHECK(!thr->is_dead) so that we are sure that it does not happen.

Not sure how widely os_lock_lock is used, maybe it needs the same.

================
Comment at: test/tsan/Darwin/osspinlock-norace.cc:1
@@ +1,2 @@
+// RUN: %clangxx_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s
+#include <libkern/OSAtomic.h>
----------------
please also add a similar test for os_lock_lock


http://reviews.llvm.org/D14987





More information about the llvm-commits mailing list