Skip to content

Commit cda4130

Browse files
authored
[scudo] Do not unmap the memory containing the this object in unmapRingBuffer (#83034)
1 parent 54cff50 commit cda4130

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1610,8 +1610,12 @@ class Allocator {
16101610
// is very important.
16111611
RB->RawStackDepotMap.unmap(RB->RawStackDepotMap.getBase(),
16121612
RB->RawStackDepotMap.getCapacity());
1613-
RB->RawRingBufferMap.unmap(RB->RawRingBufferMap.getBase(),
1614-
RB->RawRingBufferMap.getCapacity());
1613+
// Note that the `RB->RawRingBufferMap` is stored on the pages managed by
1614+
// itself. Take over the ownership before calling unmap() so that any
1615+
// operation along with unmap() won't touch inaccessible pages.
1616+
MemMapT RawRingBufferMap = RB->RawRingBufferMap;
1617+
RawRingBufferMap.unmap(RawRingBufferMap.getBase(),
1618+
RawRingBufferMap.getCapacity());
16151619
atomic_store(&RingBufferAddress, 0, memory_order_release);
16161620
}
16171621

0 commit comments

Comments
 (0)