[compiler-rt] 47bd46e - allocation_ring_buffer_size to 0 disables stack collection
Florian Mayer via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 13 09:56:20 PST 2023
Author: Florian Mayer
Date: 2023-01-13T09:56:12-08:00
New Revision: 47bd46e20c7ede9268cbcd9401816619b2197bcc
URL: https://github.com/llvm/llvm-project/commit/47bd46e20c7ede9268cbcd9401816619b2197bcc
DIFF: https://github.com/llvm/llvm-project/commit/47bd46e20c7ede9268cbcd9401816619b2197bcc.diff
LOG: allocation_ring_buffer_size to 0 disables stack collection
Reviewed By: hctim, eugenis
Differential Revision: https://reviews.llvm.org/D141631
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 37d94e39eeb7..da8104cca7e5 100644
--- a/compiler-rt/lib/scudo/standalone/combined.h
+++ b/compiler-rt/lib/scudo/standalone/combined.h
@@ -901,6 +901,10 @@ class Allocator {
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
@@ -939,7 +943,8 @@ class Allocator {
uptr getRingBufferSize() {
initThreadMaybe();
- return ringBufferSizeInBytes(getRingBuffer()->Size);
+ auto *RingBuffer = getRingBuffer();
+ return RingBuffer ? ringBufferSizeInBytes(RingBuffer->Size) : 0;
}
static bool setRingBufferSizeForBuffer(char *Buffer, size_t Size) {
@@ -1406,8 +1411,8 @@ class Allocator {
const char *RingBufferPtr) {
auto *RingBuffer =
reinterpret_cast<const AllocationRingBuffer *>(RingBufferPtr);
- if (!RingBuffer)
- return; // just in case; called before init
+ if (!RingBuffer || RingBuffer->Size == 0)
+ return;
uptr Pos = atomic_load_relaxed(&RingBuffer->Pos);
for (uptr I = Pos - 1;
@@ -1493,9 +1498,8 @@ class Allocator {
void initRingBuffer() {
u32 AllocationRingBufferSize =
static_cast<u32>(getFlags()->allocation_ring_buffer_size);
- // Have at least one entry so we don't need to special case.
if (AllocationRingBufferSize < 1)
- AllocationRingBufferSize = 1;
+ return;
MapPlatformData Data = {};
RawRingBuffer = static_cast<char *>(
map(/*Addr=*/nullptr,
More information about the llvm-commits
mailing list