about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJubilee <46493976+workingjubilee@users.noreply.github.com>2023-07-15 01:07:14 -0700
committerJubilee Young <workingjubilee@gmail.com>2023-07-19 00:22:04 -0700
commit3dee9775a8c94e701a08f7b2df2c444f353d8699 (patch)
tree3d65d54a8fe3f3c9bc493a407927c21b0a136b74
parent1e65b5b741719cc4a7bee80fc4c5299a95f8d631 (diff)
downloadrust-3dee9775a8c94e701a08f7b2df2c444f353d8699.tar.gz
rust-3dee9775a8c94e701a08f7b2df2c444f353d8699.zip
Clarify arbitrary constants
First, we reuse the `MAX_FRAMES` constant.

Co-authored-by: erikdesjardins <erikdesjardins@users.noreply.github.com>

Then we choose an arbitrary recursion depth for
the other case. In this case, I used 2d20. Honest.
-rw-r--r--compiler/rustc_driver_impl/src/signal_handler.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/compiler/rustc_driver_impl/src/signal_handler.rs b/compiler/rustc_driver_impl/src/signal_handler.rs
index 5971562627c..deca1082221 100644
--- a/compiler/rustc_driver_impl/src/signal_handler.rs
+++ b/compiler/rustc_driver_impl/src/signal_handler.rs
@@ -87,14 +87,15 @@ extern "C" fn print_stack_trace(_: libc::c_int) {
     raw_errln!("");
     written += rem.len() + 1;
 
-    if cyclic || stack.len() == 256 {
+    let random_depth = || 8 * 16; // chosen by random diceroll (2d20)
+    if cyclic || stack.len() > random_depth() {
         // technically speculation, but assert it with confidence anyway.
         // rustc only arrived in this signal handler because bad things happened
         // and this message is for explaining it's not the programmer's fault
         raw_errln!("note: rustc unexpectedly overflowed its stack! this is a bug");
         written += 1;
     }
-    if stack.len() == 256 {
+    if stack.len() == MAX_FRAMES {
         raw_errln!("note: maximum backtrace depth reached, frames may have been lost");
         written += 1;
     }