From 9c12237d2d0643fcf34ad6d027ce78d285e40271 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Wed, 8 May 2019 19:11:01 -0400 Subject: [PATCH] std.debug: fix stack trace iteration code Previously, the stack trace iteration code was using the number of frames collected as the number of frames to print, not recognizing the fixed size of the buffer. So it would redundantly print items, matching the total number of frames ever collected. Now the iteration code is limited to the actual stack trace frame count, and will not print duplicate frames. Closes #2447 Closes #2151 --- std/debug.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/std/debug.zig b/std/debug.zig index c5741f39096b..7f1a249f7ae4 100644 --- a/std/debug.zig +++ b/std/debug.zig @@ -214,7 +214,7 @@ pub fn writeStackTrace( tty_color: bool, ) !void { var frame_index: usize = 0; - var frames_left: usize = stack_trace.index; + var frames_left: usize = std.math.min(stack_trace.index, stack_trace.instruction_addresses.len); while (frames_left != 0) : ({ frames_left -= 1;