[compiler-rt] b345952 - Revert "tsan: add a test for stack init race"
Kevin Athey via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 27 15:32:16 PDT 2021
Author: Kevin Athey
Date: 2021-09-27T15:31:23-07:00
New Revision: b345952ad42655a437780e796cd0d7b6c4ccb559
URL: https://github.com/llvm/llvm-project/commit/b345952ad42655a437780e796cd0d7b6c4ccb559
DIFF: https://github.com/llvm/llvm-project/commit/b345952ad42655a437780e796cd0d7b6c4ccb559.diff
LOG: Revert "tsan: add a test for stack init race"
This reverts commit b72176b9bc06146d12e495167977effe050dc326.
Broke bot: https://lab.llvm.org/buildbot/#/builders/70/builds/12193
Added:
Modified:
compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cpp
Removed:
compiler-rt/test/tsan/stack_race3.cpp
################################################################################
diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cpp b/compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cpp
index 61133a4a3e7e..67b12c804fb2 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cpp
+++ b/compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cpp
@@ -138,8 +138,6 @@ void ThreadContext::OnCreated(void *arg) {
creation_stack_id = CurrentStackId(args->thr, args->pc);
}
-extern "C" void __tsan_stack_initialization() {}
-
struct OnStartedArgs {
ThreadState *thr;
uptr stk_addr;
@@ -175,15 +173,9 @@ void ThreadStart(ThreadState *thr, Tid tid, tid_t os_id,
#endif
#if !SANITIZER_GO
- // Don't imitate stack/TLS writes for the main thread,
- // because its initialization is synchronized with all
- // subsequent threads anyway.
if (tid != kMainTid) {
- if (stk_addr && stk_size) {
- const uptr pc = StackTrace::GetNextInstructionPc(
- reinterpret_cast<uptr>(__tsan_stack_initialization));
- MemoryRangeImitateWrite(thr, pc, stk_addr, stk_size);
- }
+ if (stk_addr && stk_size)
+ MemoryRangeImitateWrite(thr, /*pc=*/1, stk_addr, stk_size);
if (tls_addr && tls_size)
ImitateTlsWrite(thr, tls_addr, tls_size);
diff --git a/compiler-rt/test/tsan/stack_race3.cpp b/compiler-rt/test/tsan/stack_race3.cpp
deleted file mode 100644
index 854ca1dc6eff..000000000000
--- a/compiler-rt/test/tsan/stack_race3.cpp
+++ /dev/null
@@ -1,34 +0,0 @@
-// RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s
-
-// Race with initial stack initialization:
-// there is no explicit second write,
-// but the stack variable is published unsafely.
-#include "test.h"
-
-long *P;
-
-void *Thread(void *a) {
- long X;
- __atomic_store_n(&P, &X, __ATOMIC_RELAXED);
- barrier_wait(&barrier);
- barrier_wait(&barrier);
- return 0;
-}
-
-int main() {
- barrier_init(&barrier, 2);
- pthread_t t;
- pthread_create(&t, NULL, Thread, NULL);
- barrier_wait(&barrier);
- long *p = __atomic_load_n(&P, __ATOMIC_RELAXED);
- *p = 42;
- barrier_wait(&barrier);
- pthread_join(t, 0);
-}
-
-// CHECK: WARNING: ThreadSanitizer: data race
-// CHECK: Write of size 8 at {{.*}} by main thread:
-// CHECK: #0 main
-// CHECK: Previous write of size 8 at {{.*}} by thread T1:
-// CHECK: #0 __tsan_stack_initialization
-// CHECK: Location is stack of thread T1
More information about the llvm-commits
mailing list