[compiler-rt] allocation_ring_buffer_size <= 0 disables buffer (PR #71791)

Florian Mayer via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 9 02:41:09 PST 2023


https://github.com/fmayer created https://github.com/llvm/llvm-project/pull/71791

Prevent a null pointer exception for allocation_ring_buffer_size < 0.

>From 78c1ff55a3d230e87681c2a2dcc64d4184ba0a81 Mon Sep 17 00:00:00 2001
From: Florian Mayer <fmayer at google.com>
Date: Thu, 9 Nov 2023 02:28:19 -0800
Subject: [PATCH] allocation_ring_buffer_size <= 0 disables buffer

Prevent a null pointer exception for allocation_ring_buffer_size < 0.
---
 compiler-rt/lib/scudo/standalone/combined.h | 2 +-
 compiler-rt/lib/scudo/standalone/flags.inc  | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/compiler-rt/lib/scudo/standalone/combined.h b/compiler-rt/lib/scudo/standalone/combined.h
index b1700e5ecef7f5b..cb48c8c1e3a1e77 100644
--- a/compiler-rt/lib/scudo/standalone/combined.h
+++ b/compiler-rt/lib/scudo/standalone/combined.h
@@ -886,7 +886,7 @@ class Allocator {
 
   void setTrackAllocationStacks(bool Track) {
     initThreadMaybe();
-    if (getFlags()->allocation_ring_buffer_size == 0) {
+    if (getFlags()->allocation_ring_buffer_size <= 0) {
       DCHECK(!Primary.Options.load().get(OptionBit::TrackAllocationStacks));
       return;
     }
diff --git a/compiler-rt/lib/scudo/standalone/flags.inc b/compiler-rt/lib/scudo/standalone/flags.inc
index 60aeb1f1df570ac..f5a2bab5057ae13 100644
--- a/compiler-rt/lib/scudo/standalone/flags.inc
+++ b/compiler-rt/lib/scudo/standalone/flags.inc
@@ -47,4 +47,5 @@ SCUDO_FLAG(int, release_to_os_interval_ms, SCUDO_ANDROID ? INT32_MIN : 5000,
            "memory to the OS. Negative values disable the feature.")
 
 SCUDO_FLAG(int, allocation_ring_buffer_size, 32768,
-           "Entries to keep in the allocation ring buffer for scudo.")
+           "Entries to keep in the allocation ring buffer for scudo. "
+           "Values less or equal to zero disable the buffer.")



More information about the llvm-commits mailing list