[compiler-rt] 700d16b - [tsan] Fix Darwin crash after D115759
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 20 17:05:55 PST 2021
Author: Vitaly Buka
Date: 2021-12-20T17:05:41-08:00
New Revision: 700d16b6d6d3f86dc0296151ee3ca145dc78a095
URL: https://github.com/llvm/llvm-project/commit/700d16b6d6d3f86dc0296151ee3ca145dc78a095
DIFF: https://github.com/llvm/llvm-project/commit/700d16b6d6d3f86dc0296151ee3ca145dc78a095.diff
LOG: [tsan] Fix Darwin crash after D115759
Remove global constructor which may or may not be needed for Android,
at it breaks Darwin now.
Added:
Modified:
compiler-rt/lib/tsan/rtl/tsan_rtl.cpp
Removed:
################################################################################
diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl.cpp b/compiler-rt/lib/tsan/rtl/tsan_rtl.cpp
index 8822ebaea4fc7..d9885c9474736 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_rtl.cpp
+++ b/compiler-rt/lib/tsan/rtl/tsan_rtl.cpp
@@ -418,11 +418,11 @@ void MemoryProfiler(u64 uptime) {
WriteToFile(ctx->memprof_fd, buf.data(), internal_strlen(buf.data()));
}
-void InitializeMemoryProfiler() {
+static bool InitializeMemoryProfiler() {
ctx->memprof_fd = kInvalidFd;
const char *fname = flags()->profile_memory;
if (!fname || !fname[0])
- return;
+ return false;
if (internal_strcmp(fname, "stdout") == 0) {
ctx->memprof_fd = 1;
} else if (internal_strcmp(fname, "stderr") == 0) {
@@ -434,11 +434,11 @@ void InitializeMemoryProfiler() {
if (ctx->memprof_fd == kInvalidFd) {
Printf("ThreadSanitizer: failed to open memory profile file '%s'\n",
filename.data());
- return;
+ return false;
}
}
MemoryProfiler(0);
- MaybeSpawnBackgroundThread();
+ return true;
}
static void *BackgroundThread(void *arg) {
@@ -689,7 +689,8 @@ void Initialize(ThreadState *thr) {
#if !SANITIZER_GO
Symbolizer::LateInitialize();
- InitializeMemoryProfiler();
+ if (InitializeMemoryProfiler() || flags()->force_background_thread)
+ MaybeSpawnBackgroundThread();
#endif
ctx->initialized = true;
@@ -703,18 +704,6 @@ void Initialize(ThreadState *thr) {
OnInitialize();
}
-#if !SANITIZER_GO
-# pragma clang diagnostic push
-// We intentionally use a global constructor to delay the pthread call.
-# pragma clang diagnostic ignored "-Wglobal-constructors"
-static bool UNUSED __local_tsan_dyninit = [] {
- if (flags()->force_background_thread)
- MaybeSpawnBackgroundThread();
- return false;
-}();
-# pragma clang diagnostic pop
-#endif
-
void MaybeSpawnBackgroundThread() {
// On MIPS, TSan initialization is run before
// __pthread_initialize_minimal_internal() is finished, so we can not spawn
More information about the llvm-commits
mailing list