Skip to content

Commit 6ddb25e

Browse files
authored
[scudo] increase frames per stack to 16 for stack depot (#82427)
8 was very low and it is likely that in real workloads we have more than an average of 8 frames per stack given on Android we have 3 at the bottom: __start_main, __libc_init, main, and three at the top: malloc, scudo_malloc and Allocator::allocate. That leaves 2 frames for application code, which is clearly unreasonable.
1 parent 744c005 commit 6ddb25e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1522,7 +1522,12 @@ class Allocator {
15221522
constexpr u32 kStacksPerRingBufferEntry = 2;
15231523
constexpr u32 kMaxU32Pow2 = ~(UINT32_MAX >> 1);
15241524
static_assert(isPowerOfTwo(kMaxU32Pow2));
1525-
constexpr u32 kFramesPerStack = 8;
1525+
// On Android we always have 3 frames at the bottom: __start_main,
1526+
// __libc_init, main, and 3 at the top: malloc, scudo_malloc and
1527+
// Allocator::allocate. This leaves 10 frames for the user app. The next
1528+
// smallest power of two (8) would only leave 2, which is clearly too
1529+
// little.
1530+
constexpr u32 kFramesPerStack = 16;
15261531
static_assert(isPowerOfTwo(kFramesPerStack));
15271532

15281533
// We need StackDepot to be aligned to 8-bytes so the ring we store after

0 commit comments

Comments
 (0)