From: Dmitry Vyukov Date: Thu, 11 Nov 2021 18:17:17 +0000 (+0100) Subject: tsan: enable clone interceptor only on Linux X-Git-Tag: upstream/15.0.7~25998 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bc84b2857f5bd1550f0be4b0961d6a3ebecfa15d;p=platform%2Fupstream%2Fllvm.git 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 --- diff --git a/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp b/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp index a712a3a..c7dcd07 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 317ccda..70846da 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 #include #include