[compiler-rt] 296f7fb - [GWP-ASan] Fix atfork handlers being installed multiple times in tests

Mitch Phillips via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 10 10:16:48 PST 2023


Author: Mitch Phillips
Date: 2023-01-10T10:16:08-08:00
New Revision: 296f7fbbb5c48a961aa31b2ffa1d048e6bfbd7a1

URL: https://github.com/llvm/llvm-project/commit/296f7fbbb5c48a961aa31b2ffa1d048e6bfbd7a1
DIFF: https://github.com/llvm/llvm-project/commit/296f7fbbb5c48a961aa31b2ffa1d048e6bfbd7a1.diff

LOG: [GWP-ASan] Fix atfork handlers being installed multiple times in tests

We incorrectly install the atfork handlers multiple times in the test
harness, tracked down to the default parameter used by
CheckLateInitIsOK. This manifested in a hang if running the tests with
--gtest_repeat={>=2} as the atfork handler ran multiple times, causing
double-lock and double-unlock, which on my machine hung.

Add a check-fail for this case as well to prevent this from happening
again (it was difficult to track down and is an easy mistake to make).

Differential Revision: https://reviews.llvm.org/D139731

Added: 
    

Modified: 
    compiler-rt/lib/gwp_asan/platform_specific/guarded_pool_allocator_posix.cpp

Removed: 
    


################################################################################
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
index adb7330a431e2..c036ebe3efcc0 100644
--- 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
@@ -98,6 +98,10 @@ size_t GuardedPoolAllocator::getPlatformPageSize() {
 }
 
 void GuardedPoolAllocator::installAtFork() {
+  static bool AtForkInstalled = false;
+  if (AtForkInstalled)
+    return;
+  AtForkInstalled = true;
   auto Disable = []() {
     if (auto *S = getSingleton())
       S->disable();


        


More information about the llvm-commits mailing list