[compiler-rt] cda4130 - [scudo] Do not unmap the memory containing the this object in unmapRingBuffer (#83034)

via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 26 15:00:25 PST 2024


Author: Fabio D'Urso
Date: 2024-02-27T00:00:20+01:00
New Revision: cda413087c59ed5da46ca83e8a2e07c0ebd2e3f9

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

LOG: [scudo] Do not unmap the memory containing the this object in unmapRingBuffer (#83034)

Added: 
    

Modified: 
    compiler-rt/lib/scudo/standalone/combined.h

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/scudo/standalone/combined.h b/compiler-rt/lib/scudo/standalone/combined.h
index cd5a07be1576e9..fa6077384d9826 100644
--- a/compiler-rt/lib/scudo/standalone/combined.h
+++ b/compiler-rt/lib/scudo/standalone/combined.h
@@ -1610,8 +1610,12 @@ class Allocator {
     // is very important.
     RB->RawStackDepotMap.unmap(RB->RawStackDepotMap.getBase(),
                                RB->RawStackDepotMap.getCapacity());
-    RB->RawRingBufferMap.unmap(RB->RawRingBufferMap.getBase(),
-                               RB->RawRingBufferMap.getCapacity());
+    // Note that the `RB->RawRingBufferMap` is stored on the pages managed by
+    // itself. Take over the ownership before calling unmap() so that any
+    // operation along with unmap() won't touch inaccessible pages.
+    MemMapT RawRingBufferMap = RB->RawRingBufferMap;
+    RawRingBufferMap.unmap(RawRingBufferMap.getBase(),
+                           RawRingBufferMap.getCapacity());
     atomic_store(&RingBufferAddress, 0, memory_order_release);
   }
 


        


More information about the llvm-commits mailing list