From: Kuba Brecka Date: Thu, 24 Mar 2016 11:54:33 +0000 (+0000) Subject: [tsan] Fix fork() and fork-based tests for OS X X-Git-Tag: llvmorg-3.9.0-rc1~11061 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3bab18d4af327cdb0e2de49efe62f491899c67d0;p=platform%2Fupstream%2Fllvm.git [tsan] Fix fork() and fork-based tests for OS X On OS X, fork() under TSan asserts (in debug builds only) because REAL(fork) calls some intercepted functions, which check that no internal locks are held via CheckNoLocks(). But the wrapper of fork intentionally holds some locks. This patch fixes that by using ScopedIgnoreInterceptors during the call to REAL(fork). After that, all the fork-based tests seem to pass on OS X, so let's just remove all the UNSUPPORTED: darwin annotations we have. Differential Revision: http://reviews.llvm.org/D18409 llvm-svn: 264261 --- diff --git a/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc b/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc index f78103e..f4e1dfb 100644 --- a/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc +++ b/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc @@ -2168,7 +2168,13 @@ TSAN_INTERCEPTOR(int, fork, int fake) { return REAL(fork)(fake); SCOPED_INTERCEPTOR_RAW(fork, fake); ForkBefore(thr, pc); - int pid = REAL(fork)(fake); + int pid; + { + // On OS X, REAL(fork) can call intercepted functions (OSSpinLockLock), and + // we'll assert in CheckNoLocks() unless we ignore interceptors. + ScopedIgnoreInterceptors ignore; + pid = REAL(fork)(fake); + } if (pid == 0) { // child ForkChildAfter(thr, pc); diff --git a/compiler-rt/test/tsan/fork_atexit.cc b/compiler-rt/test/tsan/fork_atexit.cc index 51a64fc..15cf0a2 100644 --- a/compiler-rt/test/tsan/fork_atexit.cc +++ b/compiler-rt/test/tsan/fork_atexit.cc @@ -1,5 +1,4 @@ // RUN: %clangxx_tsan -O1 %s -o %t && %env_tsan_opts=atexit_sleep_ms=50 %run %t 2>&1 | FileCheck %s -// UNSUPPORTED: darwin #include #include #include diff --git a/compiler-rt/test/tsan/fork_deadlock.cc b/compiler-rt/test/tsan/fork_deadlock.cc index 22bed08..5dce990b 100644 --- a/compiler-rt/test/tsan/fork_deadlock.cc +++ b/compiler-rt/test/tsan/fork_deadlock.cc @@ -1,5 +1,4 @@ // RUN: %clangxx_tsan -O1 %s -o %t && %env_tsan_opts=atexit_sleep_ms=50 %run %t 2>&1 | FileCheck %s -// UNSUPPORTED: darwin #include "test.h" #include #include diff --git a/compiler-rt/test/tsan/fork_multithreaded.cc b/compiler-rt/test/tsan/fork_multithreaded.cc index b345f58..33eef93 100644 --- a/compiler-rt/test/tsan/fork_multithreaded.cc +++ b/compiler-rt/test/tsan/fork_multithreaded.cc @@ -1,6 +1,5 @@ // RUN: %clangxx_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s -check-prefix=CHECK-DIE // RUN: %clangxx_tsan -O1 %s -o %t && %env_tsan_opts=die_after_fork=0 %run %t 2>&1 | FileCheck %s -check-prefix=CHECK-NODIE -// UNSUPPORTED: darwin #include "test.h" #include #include diff --git a/compiler-rt/test/tsan/fork_multithreaded3.cc b/compiler-rt/test/tsan/fork_multithreaded3.cc index 5b8c13e..a651b3c 100644 --- a/compiler-rt/test/tsan/fork_multithreaded3.cc +++ b/compiler-rt/test/tsan/fork_multithreaded3.cc @@ -1,5 +1,4 @@ // RUN: %clangxx_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s -// UNSUPPORTED: darwin #include #include #include diff --git a/compiler-rt/test/tsan/vfork.cc b/compiler-rt/test/tsan/vfork.cc index 98a8262..5ae1dd1 100644 --- a/compiler-rt/test/tsan/vfork.cc +++ b/compiler-rt/test/tsan/vfork.cc @@ -1,5 +1,4 @@ // RUN: %clangxx_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s -// UNSUPPORTED: darwin #include #include #include