diff --git a/compiler-rt/lib/scudo/standalone/combined.h b/compiler-rt/lib/scudo/standalone/combined.h --- a/compiler-rt/lib/scudo/standalone/combined.h +++ b/compiler-rt/lib/scudo/standalone/combined.h @@ -903,6 +903,10 @@ void setTrackAllocationStacks(bool Track) { initThreadMaybe(); + if (getFlags()->allocation_ring_buffer_size == 0) { + DCHECK(!Primary.Options.get(OptionsBit::TrackAllocationStacks)); + return; + } if (Track) Primary.Options.set(OptionBit::TrackAllocationStacks); else @@ -1495,7 +1499,9 @@ void initRingBuffer() { u32 AllocationRingBufferSize = static_cast(getFlags()->allocation_ring_buffer_size); - // Have at least one entry so we don't need to special case. + // If allocation_ring_buffer_size is zero we allocate a placeholder as not + // to confuse downstream users of this buffer, but we don't use it because + // we disallow setTrackAllocationStacks. if (AllocationRingBufferSize < 1) AllocationRingBufferSize = 1; MapPlatformData Data = {};