diff --git a/compiler-rt/lib/gwp_asan/platform_specific/guarded_pool_allocator_posix.cpp b/compiler-rt/lib/gwp_asan/platform_specific/guarded_pool_allocator_posix.cpp --- a/compiler-rt/lib/gwp_asan/platform_specific/guarded_pool_allocator_posix.cpp +++ b/compiler-rt/lib/gwp_asan/platform_specific/guarded_pool_allocator_posix.cpp @@ -97,7 +97,11 @@ return sysconf(_SC_PAGESIZE); } +static bool AtForkHandlersInstalled = false; void GuardedPoolAllocator::installAtFork() { + Check(!AtForkHandlersInstalled, + "atfork() handlers can only be installed once."); + AtForkHandlersInstalled = true; auto Disable = []() { if (auto *S = getSingleton()) S->disable(); diff --git a/compiler-rt/lib/gwp_asan/tests/late_init.cpp b/compiler-rt/lib/gwp_asan/tests/late_init.cpp --- a/compiler-rt/lib/gwp_asan/tests/late_init.cpp +++ b/compiler-rt/lib/gwp_asan/tests/late_init.cpp @@ -19,6 +19,7 @@ gwp_asan::options::Options Opts; Opts.Enabled = true; Opts.SampleRate = 1; + Opts.InstallForkHandlers = false; GPA.init(Opts); EXPECT_TRUE(GPA.shouldSample());