forked from OSchip/llvm-project
[tsan] Fix Darwin crash after D115759
Remove global constructor which may or may not be needed for Android, at it breaks Darwin now.
This commit is contained in:
parent
f819db11de
commit
700d16b6d6
|
@ -418,11 +418,11 @@ void MemoryProfiler(u64 uptime) {
|
||||||
WriteToFile(ctx->memprof_fd, buf.data(), internal_strlen(buf.data()));
|
WriteToFile(ctx->memprof_fd, buf.data(), internal_strlen(buf.data()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void InitializeMemoryProfiler() {
|
static bool InitializeMemoryProfiler() {
|
||||||
ctx->memprof_fd = kInvalidFd;
|
ctx->memprof_fd = kInvalidFd;
|
||||||
const char *fname = flags()->profile_memory;
|
const char *fname = flags()->profile_memory;
|
||||||
if (!fname || !fname[0])
|
if (!fname || !fname[0])
|
||||||
return;
|
return false;
|
||||||
if (internal_strcmp(fname, "stdout") == 0) {
|
if (internal_strcmp(fname, "stdout") == 0) {
|
||||||
ctx->memprof_fd = 1;
|
ctx->memprof_fd = 1;
|
||||||
} else if (internal_strcmp(fname, "stderr") == 0) {
|
} else if (internal_strcmp(fname, "stderr") == 0) {
|
||||||
|
@ -434,11 +434,11 @@ void InitializeMemoryProfiler() {
|
||||||
if (ctx->memprof_fd == kInvalidFd) {
|
if (ctx->memprof_fd == kInvalidFd) {
|
||||||
Printf("ThreadSanitizer: failed to open memory profile file '%s'\n",
|
Printf("ThreadSanitizer: failed to open memory profile file '%s'\n",
|
||||||
filename.data());
|
filename.data());
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MemoryProfiler(0);
|
MemoryProfiler(0);
|
||||||
MaybeSpawnBackgroundThread();
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *BackgroundThread(void *arg) {
|
static void *BackgroundThread(void *arg) {
|
||||||
|
@ -689,7 +689,8 @@ void Initialize(ThreadState *thr) {
|
||||||
|
|
||||||
#if !SANITIZER_GO
|
#if !SANITIZER_GO
|
||||||
Symbolizer::LateInitialize();
|
Symbolizer::LateInitialize();
|
||||||
InitializeMemoryProfiler();
|
if (InitializeMemoryProfiler() || flags()->force_background_thread)
|
||||||
|
MaybeSpawnBackgroundThread();
|
||||||
#endif
|
#endif
|
||||||
ctx->initialized = true;
|
ctx->initialized = true;
|
||||||
|
|
||||||
|
@ -703,18 +704,6 @@ void Initialize(ThreadState *thr) {
|
||||||
OnInitialize();
|
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() {
|
void MaybeSpawnBackgroundThread() {
|
||||||
// On MIPS, TSan initialization is run before
|
// On MIPS, TSan initialization is run before
|
||||||
// __pthread_initialize_minimal_internal() is finished, so we can not spawn
|
// __pthread_initialize_minimal_internal() is finished, so we can not spawn
|
||||||
|
|
Loading…
Reference in New Issue