[compiler-rt] [scudo] Allow to resize allocation ring buffer (PR #82683)

Florian Mayer via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 11 17:05:18 PDT 2024


================
@@ -1594,12 +1600,33 @@ class Allocator {
     RB->StackDepotSize = StackDepotSize;
     RB->RawStackDepotMap = DepotMap;
 
-    atomic_store(&RingBufferAddress, reinterpret_cast<uptr>(RB),
-                 memory_order_release);
+    swapOutRingBuffer(RB);
     static_assert(sizeof(AllocationRingBuffer) %
                           alignof(typename AllocationRingBuffer::Entry) ==
                       0,
                   "invalid alignment");
+    return true;
+  }
+
+  void swapOutRingBuffer(AllocationRingBuffer *NewRB) {
+    // To allow resizeRingBuffer to be called in a multi-threaded context by apps,
+    // we do not actually unmap, but only madvise(DONTNEED) the pages. That way,
+    // straggler threads will not crash.
----------------
fmayer wrote:

I don't see how we would do this for apps. That would require all apps to call `malloc_set_track_allocation_stacks` themselves, otherwise they don't get any. Currently, the platform does this for them, but we wouldn't know whether we should do that, or the app wants to change the ring buffer size and thus call it itself.

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


More information about the llvm-commits mailing list