Index: compiler-rt/lib/asan/asan_thread.h =================================================================== --- compiler-rt/lib/asan/asan_thread.h +++ compiler-rt/lib/asan/asan_thread.h @@ -68,7 +68,7 @@ void Destroy(); struct InitOptions; - void Init(const InitOptions *options = nullptr); + void Init(const InitOptions *options = nullptr, bool init_fake_stack = false); thread_return_t ThreadStart(tid_t os_id, atomic_uintptr_t *signal_thread_is_registered); Index: compiler-rt/lib/asan/asan_thread.cc =================================================================== --- compiler-rt/lib/asan/asan_thread.cc +++ compiler-rt/lib/asan/asan_thread.cc @@ -222,16 +222,18 @@ return nullptr; } -void AsanThread::Init(const InitOptions *options) { +void AsanThread::Init(const InitOptions *options, bool init_fake_stack) { next_stack_top_ = next_stack_bottom_ = 0; atomic_store(&stack_switching_, false, memory_order_release); - fake_stack_ = nullptr; // Will be initialized lazily if needed. + fake_stack_ = nullptr; // Will be initialized below, or lazily if needed. CHECK_EQ(this->stack_size(), 0U); SetThreadStackAndTls(options); CHECK_GT(this->stack_size(), 0U); CHECK(AddrIsInMem(stack_bottom_)); CHECK(AddrIsInMem(stack_top_ - 1)); ClearShadowForThreadStackAndTLS(); + if (__asan_option_detect_stack_use_after_return && init_fake_stack) + AsyncSignalSafeLazyInitFakeStack(); int local = 0; VReport(1, "T%d: stack [%p,%p) size 0x%zx; local=%p\n", tid(), (void *)stack_bottom_, (void *)stack_top_, stack_top_ - stack_bottom_,