Revert "tsan: add a test for stack init race"

This reverts commit b72176b9bc.

Broke bot: https://lab.llvm.org/buildbot/#/builders/70/builds/12193
This commit is contained in:
Kevin Athey 2021-09-27 14:48:44 -07:00
parent 57cd7b018c
commit b345952ad4
2 changed files with 2 additions and 44 deletions

View File

@ -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);

View File

@ -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