[compiler-rt] bc84b28 - tsan: enable clone interceptor only on Linux

Dmitry Vyukov via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 11 10:27:51 PST 2021


Author: Dmitry Vyukov
Date: 2021-11-11T19:27:47+01:00
New Revision: bc84b2857f5bd1550f0be4b0961d6a3ebecfa15d

URL: https://github.com/llvm/llvm-project/commit/bc84b2857f5bd1550f0be4b0961d6a3ebecfa15d
DIFF: https://github.com/llvm/llvm-project/commit/bc84b2857f5bd1550f0be4b0961d6a3ebecfa15d.diff

LOG: tsan: enable clone interceptor only on Linux

Clone does not exist on Mac.
There are chances it will break on other OSes.
Enable it incrementally starting with Linux only,
other OSes can enable it later as needed.

Reviewed By: melver, thakis

Differential Revision: https://reviews.llvm.org/D113693

Added: 
    compiler-rt/test/tsan/Linux/clone_deadlock.cpp

Modified: 
    compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp

Removed: 
    compiler-rt/test/tsan/clone_deadlock.cpp


################################################################################
diff  --git a/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp b/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
index a712a3ad5bd9c..c7dcd07b85296 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
+++ b/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
@@ -2210,6 +2210,7 @@ TSAN_INTERCEPTOR(int, vfork, int fake) {
   return WRAP(fork)(fake);
 }
 
+#if SANITIZER_LINUX
 TSAN_INTERCEPTOR(int, clone, int (*fn)(void *), void *stack, int flags,
                  void *arg, int *parent_tid, void *tls, pid_t *child_tid) {
   SCOPED_INTERCEPTOR_RAW(clone, fn, stack, flags, arg, parent_tid, tls,
@@ -2233,6 +2234,7 @@ TSAN_INTERCEPTOR(int, clone, int (*fn)(void *), void *stack, int flags,
   ForkParentAfter(thr, pc);
   return pid;
 }
+#endif
 
 #if !SANITIZER_MAC && !SANITIZER_ANDROID
 typedef int (*dl_iterate_phdr_cb_t)(__sanitizer_dl_phdr_info *info, SIZE_T size,
@@ -2865,7 +2867,9 @@ void InitializeInterceptors() {
 
   TSAN_INTERCEPT(fork);
   TSAN_INTERCEPT(vfork);
+#if SANITIZER_LINUX
   TSAN_INTERCEPT(clone);
+#endif
 #if !SANITIZER_ANDROID
   TSAN_INTERCEPT(dl_iterate_phdr);
 #endif

diff  --git a/compiler-rt/test/tsan/clone_deadlock.cpp b/compiler-rt/test/tsan/Linux/clone_deadlock.cpp
similarity index 97%
rename from compiler-rt/test/tsan/clone_deadlock.cpp
rename to compiler-rt/test/tsan/Linux/clone_deadlock.cpp
index 317ccdabdb704..70846da7d10ad 100644
--- a/compiler-rt/test/tsan/clone_deadlock.cpp
+++ b/compiler-rt/test/tsan/Linux/clone_deadlock.cpp
@@ -1,5 +1,5 @@
 // RUN: %clangxx_tsan -O1 %s -o %t && %env_tsan_opts=atexit_sleep_ms=0 %run %t 2>&1 | FileCheck %s
-#include "test.h"
+#include "../test.h"
 #include <errno.h>
 #include <sched.h>
 #include <sys/types.h>


        


More information about the llvm-commits mailing list