From f74e10cd4722512ac671f574b3d274ab48abb1a7 Mon Sep 17 00:00:00 2001 From: Gregory Mullen <_@gr.ht> Date: Sun, 20 Aug 2023 12:22:53 -0700 Subject: [PATCH] Update default stack frames for general_purpose_allocator.zig Created from a conversation with @andrewrk on irc: Memory leaks when using ArrayList can be inconvenient to debug when the stack frame size is 4 because the entirety of the printed frame is within zig stdlib, and not in the users calling stack. Increasing this to 6 for Debug builds, gives 2 frames of user code. I increased the frame size for tests as well by the equivalent factor, but I'm unconvinced that's actually desirable. --- lib/std/heap/general_purpose_allocator.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/std/heap/general_purpose_allocator.zig b/lib/std/heap/general_purpose_allocator.zig index b839807855..ccc4b6a8b2 100644 --- a/lib/std/heap/general_purpose_allocator.zig +++ b/lib/std/heap/general_purpose_allocator.zig @@ -105,7 +105,7 @@ const StackTrace = std.builtin.StackTrace; /// Integer type for pointing to slots in a small allocation const SlotIndex = std.meta.Int(.unsigned, math.log2(page_size) + 1); -const default_test_stack_trace_frames: usize = if (builtin.is_test) 8 else 4; +const default_test_stack_trace_frames: usize = if (builtin.is_test) 10 else 6; const default_sys_stack_trace_frames: usize = if (std.debug.sys_can_stack_trace) default_test_stack_trace_frames else 0; const default_stack_trace_frames: usize = switch (builtin.mode) { .Debug => default_sys_stack_trace_frames,