[compiler-rt] [scudo] Only init RingBuffer when needed. (PR #85994)

Christopher Ferris via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 27 20:19:09 PDT 2024


================
@@ -1546,11 +1547,17 @@ class Allocator {
         RBEntryStart)[N];
   }
 
-  void mapAndInitializeRingBuffer() {
-    if (getFlags()->allocation_ring_buffer_size <= 0)
+  void initRingBufferMaybe() {
+    static HybridMutex RingBufferLock;
+    ScopedLock L(RingBufferLock);
----------------
cferris1000 wrote:

Yeah, I made it global and and added it to the enable/disable code.

There is a chance that if someone forks while the code holds the init lock, but before the ring buffer is finished, trying to init in the forked process would deadlock.

https://github.com/llvm/llvm-project/pull/85994


More information about the llvm-commits mailing list