Index: compiler-rt/lib/scudo/standalone/combined.h =================================================================== --- compiler-rt/lib/scudo/standalone/combined.h +++ compiler-rt/lib/scudo/standalone/combined.h @@ -228,6 +228,7 @@ } void unmapTestOnly() { + destroyRingBuffer(); TSDRegistry.unmapTestOnly(this); Primary.unmapTestOnly(); Secondary.unmapTestOnly(); @@ -1503,12 +1504,11 @@ static_cast(getFlags()->allocation_ring_buffer_size); if (AllocationRingBufferSize < 1) return; - MapPlatformData Data = {}; RawRingBuffer = static_cast( map(/*Addr=*/nullptr, roundUp(ringBufferSizeInBytes(AllocationRingBufferSize), getPageSizeCached()), - "AllocatorRingBuffer", /*Flags=*/0, &Data)); + "AllocatorRingBuffer")); auto *RingBuffer = reinterpret_cast(RawRingBuffer); RingBuffer->Size = AllocationRingBufferSize; static_assert(sizeof(AllocationRingBuffer) % @@ -1517,6 +1517,13 @@ "invalid alignment"); } + void destroyRingBuffer() { + auto *RingBuffer = reinterpret_cast(RawRingBuffer); + unmap(RawRingBuffer, roundUp(ringBufferSizeInBytes(RingBuffer->Size), + getPageSizeCached())); + RawRingBuffer = nullptr; + } + static constexpr size_t ringBufferSizeInBytes(u32 AllocationRingBufferSize) { return sizeof(AllocationRingBuffer) + AllocationRingBufferSize *