Skip to content

Commit

Permalink
Revert "tsan: fix and test detection of TLS races"
Browse files Browse the repository at this point in the history
This reverts commit b4c1e5c.

Reverting this as it contains a test that is currently failing on the PPC BE bots.
  • Loading branch information
amy-kwan committed Oct 1, 2021
1 parent 8b1984b commit 103c1bd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 51 deletions.
9 changes: 3 additions & 6 deletions compiler-rt/lib/tsan/rtl/tsan_platform_linux.cpp
Expand Up @@ -453,8 +453,6 @@ static void InitializeLongjmpXorKey() {
}
#endif

extern "C" void __tsan_tls_initialization() {}

void ImitateTlsWrite(ThreadState *thr, uptr tls_addr, uptr tls_size) {
// Check that the thr object is in tls;
const uptr thr_beg = (uptr)thr;
Expand All @@ -464,10 +462,9 @@ void ImitateTlsWrite(ThreadState *thr, uptr tls_addr, uptr tls_size) {
CHECK_GE(thr_end, tls_addr);
CHECK_LE(thr_end, tls_addr + tls_size);
// Since the thr object is huge, skip it.
const uptr pc = StackTrace::GetNextInstructionPc(
reinterpret_cast<uptr>(__tsan_tls_initialization));
MemoryRangeImitateWrite(thr, pc, tls_addr, thr_beg - tls_addr);
MemoryRangeImitateWrite(thr, pc, thr_end, tls_addr + tls_size - thr_end);
MemoryRangeImitateWrite(thr, /*pc=*/2, tls_addr, thr_beg - tls_addr);
MemoryRangeImitateWrite(thr, /*pc=*/2, thr_end,
tls_addr + tls_size - thr_end);
}

// Note: this function runs with async signals enabled,
Expand Down
17 changes: 7 additions & 10 deletions compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cpp
Expand Up @@ -156,6 +156,13 @@ void ThreadStart(ThreadState *thr, Tid tid, tid_t os_id,
if (thread_type != ThreadType::Fiber)
GetThreadStackAndTls(tid == kMainTid, &stk_addr, &stk_size, &tls_addr,
&tls_size);

if (tid != kMainTid) {
if (stk_addr && stk_size)
MemoryRangeImitateWrite(thr, /*pc=*/ 1, stk_addr, stk_size);

if (tls_addr && tls_size) ImitateTlsWrite(thr, tls_addr, tls_size);
}
#endif

ThreadRegistry *tr = &ctx->thread_registry;
Expand All @@ -171,16 +178,6 @@ void ThreadStart(ThreadState *thr, Tid tid, tid_t os_id,
ThreadIgnoreSyncBegin(thr, 0);
}
#endif

#if !SANITIZER_GO
if (tid != kMainTid) {
if (stk_addr && stk_size)
MemoryRangeImitateWrite(thr, /*pc=*/1, stk_addr, stk_size);

if (tls_addr && tls_size)
ImitateTlsWrite(thr, tls_addr, tls_size);
}
#endif
}

void ThreadContext::OnStarted(void *arg) {
Expand Down
35 changes: 0 additions & 35 deletions compiler-rt/test/tsan/tls_race3.cpp

This file was deleted.

0 comments on commit 103c1bd

Please sign in to comment.