Skip to content

Commit 3dee977

Browse files
Clarify arbitrary constants
First, we reuse the `MAX_FRAMES` constant. Co-authored-by: erikdesjardins <[email protected]> Then we choose an arbitrary recursion depth for the other case. In this case, I used 2d20. Honest.
1 parent 1e65b5b commit 3dee977

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

compiler/rustc_driver_impl/src/signal_handler.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,15 @@ extern "C" fn print_stack_trace(_: libc::c_int) {
8787
raw_errln!("");
8888
written += rem.len() + 1;
8989

90-
if cyclic || stack.len() == 256 {
90+
let random_depth = || 8 * 16; // chosen by random diceroll (2d20)
91+
if cyclic || stack.len() > random_depth() {
9192
// technically speculation, but assert it with confidence anyway.
9293
// rustc only arrived in this signal handler because bad things happened
9394
// and this message is for explaining it's not the programmer's fault
9495
raw_errln!("note: rustc unexpectedly overflowed its stack! this is a bug");
9596
written += 1;
9697
}
97-
if stack.len() == 256 {
98+
if stack.len() == MAX_FRAMES {
9899
raw_errln!("note: maximum backtrace depth reached, frames may have been lost");
99100
written += 1;
100101
}

0 commit comments

Comments
 (0)