[PATCH] D71559: [TSan][Darwin] Avoid calling pthread_self() before libpthread is initialized
Julian Lettner via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 16 13:12:37 PST 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf9a706a36ae5: [TSan][Darwin] Avoid calling pthread_self() before libpthread is initialized (authored by yln).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D71559/new/
https://reviews.llvm.org/D71559
Files:
compiler-rt/lib/tsan/rtl/tsan_platform_mac.cpp
Index: compiler-rt/lib/tsan/rtl/tsan_platform_mac.cpp
===================================================================
--- compiler-rt/lib/tsan/rtl/tsan_platform_mac.cpp
+++ compiler-rt/lib/tsan/rtl/tsan_platform_mac.cpp
@@ -75,9 +75,14 @@
ALIGNED(64) static char main_thread_state[sizeof(ThreadState)];
static ThreadState *main_thread_state_loc = (ThreadState *)main_thread_state;
+// We cannot use pthread_self() before libpthread has been initialized. Our
+// current heuristic for guarding this is checking `main_thread_identity` which
+// is only assigned in `__tsan::InitializePlatform`.
static ThreadState **cur_thread_location() {
+ if (main_thread_identity == 0)
+ return &main_thread_state_loc;
uptr thread_identity = (uptr)pthread_self();
- if (thread_identity == main_thread_identity || main_thread_identity == 0)
+ if (thread_identity == main_thread_identity)
return &main_thread_state_loc;
return (ThreadState **)MemToShadow(thread_identity);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71559.234126.patch
Type: text/x-patch
Size: 986 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191216/ec5151d4/attachment.bin>
More information about the llvm-commits
mailing list