diff --git a/compiler-rt/lib/asan/asan_rtl.cpp b/compiler-rt/lib/asan/asan_rtl.cpp index 35b785a79e3ef..f0bbbf32e6a64 100644 --- a/compiler-rt/lib/asan/asan_rtl.cpp +++ b/compiler-rt/lib/asan/asan_rtl.cpp @@ -445,6 +445,9 @@ static void AsanInitInternal() { allocator_options.SetFrom(flags(), common_flags()); InitializeAllocator(allocator_options); + if (SANITIZER_START_BACKGROUND_THREAD_IN_ASAN_INTERNAL) + MaybeStartBackgroudThread(); + // On Linux AsanThread::ThreadStart() calls malloc() that's why asan_inited // should be set to 1 prior to initializing the threads. asan_inited = 1; diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_allocator.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_allocator.cpp index fd54357adbe44..c5a5fb7371dd9 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_allocator.cpp +++ b/compiler-rt/lib/sanitizer_common/sanitizer_allocator.cpp @@ -189,8 +189,6 @@ bool AllocatorMayReturnNull() { void SetAllocatorMayReturnNull(bool may_return_null) { atomic_store(&allocator_may_return_null, may_return_null, memory_order_relaxed); - if (SANITIZER_START_BACKGROUND_THREAD_IN_ASAN_INTERNAL) - MaybeStartBackgroudThread(); } void PrintHintAllocatorCannotReturnNull() { diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp index 13624a83865d7..271d733be6b0b 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp +++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp @@ -107,6 +107,8 @@ static struct BackgroudThreadStarted { } background_thread_strarter UNUSED; # pragma clang diagnostic pop # endif +#else +void MaybeStartBackgroudThread() {} #endif void WriteToSyslog(const char *msg) {