authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-05-08 19:11:01-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-05-08 19:11:01-04:00
log9c12237d2d0643fcf34ad6d027ce78d285e40271
tree096fae1dbd0205141ac44491bb20ad00ffbfe098
parenta4aee8b24d321aa4c7a791d20500e5847a08b587
signature Commit is signed but in an unrecognized format.

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

1 files changed, 1 insertions(+), 1 deletions(-)

std/debug.zig+1-1
...@@ -214,7 +214,7 @@ pub fn writeStackTrace(...@@ -214,7 +214,7 @@ pub fn writeStackTrace(
214 tty_color: bool,214 tty_color: bool,
215) !void {215) !void {
216 var frame_index: usize = 0;216 var frame_index: usize = 0;
217 var frames_left: usize = stack_trace.index;217 var frames_left: usize = std.math.min(stack_trace.index, stack_trace.instruction_addresses.len);
218218
219 while (frames_left != 0) : ({219 while (frames_left != 0) : ({
220 frames_left -= 1;220 frames_left -= 1;