[compiler-rt] ade5023 - tsan: fix tls_race3 test on darwin
Dmitry Vyukov via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 28 08:07:55 PDT 2021
Author: Dmitry Vyukov
Date: 2021-09-28T17:07:51+02:00
New Revision: ade5023c54cffcbefe0557b5473d55b06e40809b
URL: https://github.com/llvm/llvm-project/commit/ade5023c54cffcbefe0557b5473d55b06e40809b
DIFF: https://github.com/llvm/llvm-project/commit/ade5023c54cffcbefe0557b5473d55b06e40809b.diff
LOG: tsan: fix tls_race3 test on darwin
Darwin also needs to use __tsan_tls_initialization
to pass the test.
Differential Revision: https://reviews.llvm.org/D110631
Added:
Modified:
compiler-rt/lib/tsan/rtl/tsan_platform_mac.cpp
Removed:
################################################################################
diff --git a/compiler-rt/lib/tsan/rtl/tsan_platform_mac.cpp b/compiler-rt/lib/tsan/rtl/tsan_platform_mac.cpp
index f2aff7786e0e..659616595035 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_platform_mac.cpp
+++ b/compiler-rt/lib/tsan/rtl/tsan_platform_mac.cpp
@@ -283,13 +283,17 @@ uptr ExtractLongJmpSp(uptr *env) {
}
#if !SANITIZER_GO
+extern "C" void __tsan_tls_initialization() {}
+
void ImitateTlsWrite(ThreadState *thr, uptr tls_addr, uptr tls_size) {
// The pointer to the ThreadState object is stored in the shadow memory
// of the tls.
uptr tls_end = tls_addr + tls_size;
uptr thread_identity = (uptr)pthread_self();
+ const uptr pc = StackTrace::GetNextInstructionPc(
+ reinterpret_cast<uptr>(__tsan_tls_initialization));
if (thread_identity == main_thread_identity) {
- MemoryRangeImitateWrite(thr, /*pc=*/2, tls_addr, tls_size);
+ MemoryRangeImitateWrite(thr, pc, tls_addr, tls_size);
} else {
uptr thr_state_start = thread_identity;
uptr thr_state_end = thr_state_start + sizeof(uptr);
@@ -297,10 +301,8 @@ void ImitateTlsWrite(ThreadState *thr, uptr tls_addr, uptr tls_size) {
CHECK_LE(thr_state_start, tls_addr + tls_size);
CHECK_GE(thr_state_end, tls_addr);
CHECK_LE(thr_state_end, tls_addr + tls_size);
- MemoryRangeImitateWrite(thr, /*pc=*/2, tls_addr,
- thr_state_start - tls_addr);
- MemoryRangeImitateWrite(thr, /*pc=*/2, thr_state_end,
- tls_end - thr_state_end);
+ MemoryRangeImitateWrite(thr, pc, tls_addr, thr_state_start - tls_addr);
+ MemoryRangeImitateWrite(thr, pc, thr_state_end, tls_end - thr_state_end);
}
}
#endif
More information about the llvm-commits
mailing list