[scudo] Fix RingBuffer initialization.
authorLuke Nicholson <lukenicholson@google.com>
Thu, 12 Jan 2023 21:05:30 +0000 (13:05 -0800)
committerFlorian Mayer <fmayer@google.com>
Thu, 12 Jan 2023 21:10:27 +0000 (13:10 -0800)
Several map implementations require that map calls provide a page
aligned size.

Reviewed By: fmayer

Differential Revision: https://reviews.llvm.org/D141630

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

index 8543315..ae2aafe 100644 (file)
@@ -1500,7 +1500,8 @@ private:
       AllocationRingBufferSize = 1;
     MapPlatformData Data = {};
     RawRingBuffer = static_cast<char *>(
-        map(/*Addr=*/nullptr, ringBufferSizeInBytes(AllocationRingBufferSize),
+        map(/*Addr=*/nullptr,
+            roundUpTo(ringBufferSizeInBytes(AllocationRingBufferSize), getPageSizeCached()),
             "AllocatorRingBuffer", /*Flags=*/0, &Data));
     auto *RingBuffer = reinterpret_cast<AllocationRingBuffer *>(RawRingBuffer);
     RingBuffer->Size = AllocationRingBufferSize;