From b65beeab3a16e9c572e4701711513d25efb83bec Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 11 Jan 2025 10:35:00 +0100 Subject: [PATCH 1/2] use a single large catch_unwind in lang_start --- tests/fail/tail_calls/cc-mismatch.stderr | 10 +++++++--- tests/pass/backtrace/backtrace-api-v1.stderr | 6 +++++- tests/pass/backtrace/backtrace-global-alloc.stderr | 14 +++++++++++--- tests/pass/backtrace/backtrace-std.stderr | 14 +++++++++++--- 4 files changed, 34 insertions(+), 10 deletions(-) diff --git a/tests/fail/tail_calls/cc-mismatch.stderr b/tests/fail/tail_calls/cc-mismatch.stderr index b416f0eb68..4a0886cf89 100644 --- a/tests/fail/tail_calls/cc-mismatch.stderr +++ b/tests/fail/tail_calls/cc-mismatch.stderr @@ -15,9 +15,13 @@ LL | extern "rust-call" fn call_once(self, args: Args) -> Self::Output; = note: inside `std::panicking::r#try:: i32 + std::marker::Sync + std::panic::RefUnwindSafe>` at RUSTLIB/std/src/panicking.rs:LL:CC = note: inside `std::panic::catch_unwind::<&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe, i32>` at RUSTLIB/std/src/panic.rs:LL:CC = note: inside closure at RUSTLIB/std/src/rt.rs:LL:CC - = note: inside `std::panicking::r#try::do_call::<{closure@std::rt::lang_start_internal::{closure#1}}, isize>` at RUSTLIB/std/src/panicking.rs:LL:CC - = note: inside `std::panicking::r#try::` at RUSTLIB/std/src/panicking.rs:LL:CC - = note: inside `std::panic::catch_unwind::<{closure@std::rt::lang_start_internal::{closure#1}}, isize>` at RUSTLIB/std/src/panic.rs:LL:CC + = note: inside `std::panicking::r#try::do_call::<{closure@std::rt::lang_start_internal::{closure#0}::{closure#0}}, isize>` at RUSTLIB/std/src/panicking.rs:LL:CC + = note: inside `std::panicking::r#try::` at RUSTLIB/std/src/panicking.rs:LL:CC + = note: inside `std::panic::catch_unwind::<{closure@std::rt::lang_start_internal::{closure#0}::{closure#0}}, isize>` at RUSTLIB/std/src/panic.rs:LL:CC + = note: inside closure at RUSTLIB/std/src/rt.rs:LL:CC + = note: inside `std::panicking::r#try::do_call::<{closure@std::rt::lang_start_internal::{closure#0}}, std::result::Result>` at RUSTLIB/std/src/panicking.rs:LL:CC + = note: inside `std::panicking::r#try::, {closure@std::rt::lang_start_internal::{closure#0}}>` at RUSTLIB/std/src/panicking.rs:LL:CC + = note: inside `std::panic::catch_unwind::<{closure@std::rt::lang_start_internal::{closure#0}}, std::result::Result>` at RUSTLIB/std/src/panic.rs:LL:CC = note: inside `std::rt::lang_start_internal` at RUSTLIB/std/src/rt.rs:LL:CC = note: inside `std::rt::lang_start::<()>` at RUSTLIB/std/src/rt.rs:LL:CC diff --git a/tests/pass/backtrace/backtrace-api-v1.stderr b/tests/pass/backtrace/backtrace-api-v1.stderr index 48d9649c92..826645ba3d 100644 --- a/tests/pass/backtrace/backtrace-api-v1.stderr +++ b/tests/pass/backtrace/backtrace-api-v1.stderr @@ -10,7 +10,11 @@ RUSTLIB/core/src/ops/function.rs:LL:CC (std::ops::function::impls::call_once) RUSTLIB/std/src/panicking.rs:LL:CC (std::panicking::r#try::do_call) RUSTLIB/std/src/panicking.rs:LL:CC (std::panicking::r#try) RUSTLIB/std/src/panic.rs:LL:CC (std::panic::catch_unwind) -RUSTLIB/std/src/rt.rs:LL:CC (std::rt::lang_start_internal::{closure#1}) +RUSTLIB/std/src/rt.rs:LL:CC (std::rt::lang_start_internal::{closure#0}::{closure#0}) +RUSTLIB/std/src/panicking.rs:LL:CC (std::panicking::r#try::do_call) +RUSTLIB/std/src/panicking.rs:LL:CC (std::panicking::r#try) +RUSTLIB/std/src/panic.rs:LL:CC (std::panic::catch_unwind) +RUSTLIB/std/src/rt.rs:LL:CC (std::rt::lang_start_internal::{closure#0}) RUSTLIB/std/src/panicking.rs:LL:CC (std::panicking::r#try::do_call) RUSTLIB/std/src/panicking.rs:LL:CC (std::panicking::r#try) RUSTLIB/std/src/panic.rs:LL:CC (std::panic::catch_unwind) diff --git a/tests/pass/backtrace/backtrace-global-alloc.stderr b/tests/pass/backtrace/backtrace-global-alloc.stderr index 667ee04e62..30643bc670 100644 --- a/tests/pass/backtrace/backtrace-global-alloc.stderr +++ b/tests/pass/backtrace/backtrace-global-alloc.stderr @@ -14,7 +14,7 @@ at RUSTLIB/std/src/panicking.rs:LL:CC 7: std::panic::catch_unwind at RUSTLIB/std/src/panic.rs:LL:CC - 8: std::rt::lang_start_internal::{closure#1} + 8: std::rt::lang_start_internal::{closure#0}::{closure#0} at RUSTLIB/std/src/rt.rs:LL:CC 9: std::panicking::r#try::do_call at RUSTLIB/std/src/panicking.rs:LL:CC @@ -22,7 +22,15 @@ at RUSTLIB/std/src/panicking.rs:LL:CC 11: std::panic::catch_unwind at RUSTLIB/std/src/panic.rs:LL:CC - 12: std::rt::lang_start_internal + 12: std::rt::lang_start_internal::{closure#0} at RUSTLIB/std/src/rt.rs:LL:CC - 13: std::rt::lang_start + 13: std::panicking::r#try::do_call + at RUSTLIB/std/src/panicking.rs:LL:CC + 14: std::panicking::r#try + at RUSTLIB/std/src/panicking.rs:LL:CC + 15: std::panic::catch_unwind + at RUSTLIB/std/src/panic.rs:LL:CC + 16: std::rt::lang_start_internal + at RUSTLIB/std/src/rt.rs:LL:CC + 17: std::rt::lang_start at RUSTLIB/std/src/rt.rs:LL:CC diff --git a/tests/pass/backtrace/backtrace-std.stderr b/tests/pass/backtrace/backtrace-std.stderr index b3a3a9d654..e04d2e561d 100644 --- a/tests/pass/backtrace/backtrace-std.stderr +++ b/tests/pass/backtrace/backtrace-std.stderr @@ -22,7 +22,7 @@ at RUSTLIB/std/src/panicking.rs:LL:CC 11: std::panic::catch_unwind at RUSTLIB/std/src/panic.rs:LL:CC - 12: std::rt::lang_start_internal::{closure#1} + 12: std::rt::lang_start_internal::{closure#0}::{closure#0} at RUSTLIB/std/src/rt.rs:LL:CC 13: std::panicking::r#try::do_call at RUSTLIB/std/src/panicking.rs:LL:CC @@ -30,7 +30,15 @@ at RUSTLIB/std/src/panicking.rs:LL:CC 15: std::panic::catch_unwind at RUSTLIB/std/src/panic.rs:LL:CC - 16: std::rt::lang_start_internal + 16: std::rt::lang_start_internal::{closure#0} at RUSTLIB/std/src/rt.rs:LL:CC - 17: std::rt::lang_start + 17: std::panicking::r#try::do_call + at RUSTLIB/std/src/panicking.rs:LL:CC + 18: std::panicking::r#try + at RUSTLIB/std/src/panicking.rs:LL:CC + 19: std::panic::catch_unwind + at RUSTLIB/std/src/panic.rs:LL:CC + 20: std::rt::lang_start_internal + at RUSTLIB/std/src/rt.rs:LL:CC + 21: std::rt::lang_start at RUSTLIB/std/src/rt.rs:LL:CC From 646d845478c28ed30c5e2bff5a62e79bfa1b9e20 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 11 Jan 2025 15:43:43 +0100 Subject: [PATCH 2/2] avoid nesting the user-defined main so deeply on the stack --- tests/fail/tail_calls/cc-mismatch.stderr | 10 +++------- tests/pass/backtrace/backtrace-api-v1.stderr | 4 ---- tests/pass/backtrace/backtrace-global-alloc.stderr | 14 +++----------- tests/pass/backtrace/backtrace-std.stderr | 14 +++----------- 4 files changed, 9 insertions(+), 33 deletions(-) diff --git a/tests/fail/tail_calls/cc-mismatch.stderr b/tests/fail/tail_calls/cc-mismatch.stderr index 4a0886cf89..5061c9e8dc 100644 --- a/tests/fail/tail_calls/cc-mismatch.stderr +++ b/tests/fail/tail_calls/cc-mismatch.stderr @@ -15,13 +15,9 @@ LL | extern "rust-call" fn call_once(self, args: Args) -> Self::Output; = note: inside `std::panicking::r#try:: i32 + std::marker::Sync + std::panic::RefUnwindSafe>` at RUSTLIB/std/src/panicking.rs:LL:CC = note: inside `std::panic::catch_unwind::<&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe, i32>` at RUSTLIB/std/src/panic.rs:LL:CC = note: inside closure at RUSTLIB/std/src/rt.rs:LL:CC - = note: inside `std::panicking::r#try::do_call::<{closure@std::rt::lang_start_internal::{closure#0}::{closure#0}}, isize>` at RUSTLIB/std/src/panicking.rs:LL:CC - = note: inside `std::panicking::r#try::` at RUSTLIB/std/src/panicking.rs:LL:CC - = note: inside `std::panic::catch_unwind::<{closure@std::rt::lang_start_internal::{closure#0}::{closure#0}}, isize>` at RUSTLIB/std/src/panic.rs:LL:CC - = note: inside closure at RUSTLIB/std/src/rt.rs:LL:CC - = note: inside `std::panicking::r#try::do_call::<{closure@std::rt::lang_start_internal::{closure#0}}, std::result::Result>` at RUSTLIB/std/src/panicking.rs:LL:CC - = note: inside `std::panicking::r#try::, {closure@std::rt::lang_start_internal::{closure#0}}>` at RUSTLIB/std/src/panicking.rs:LL:CC - = note: inside `std::panic::catch_unwind::<{closure@std::rt::lang_start_internal::{closure#0}}, std::result::Result>` at RUSTLIB/std/src/panic.rs:LL:CC + = note: inside `std::panicking::r#try::do_call::<{closure@std::rt::lang_start_internal::{closure#0}}, isize>` at RUSTLIB/std/src/panicking.rs:LL:CC + = note: inside `std::panicking::r#try::` at RUSTLIB/std/src/panicking.rs:LL:CC + = note: inside `std::panic::catch_unwind::<{closure@std::rt::lang_start_internal::{closure#0}}, isize>` at RUSTLIB/std/src/panic.rs:LL:CC = note: inside `std::rt::lang_start_internal` at RUSTLIB/std/src/rt.rs:LL:CC = note: inside `std::rt::lang_start::<()>` at RUSTLIB/std/src/rt.rs:LL:CC diff --git a/tests/pass/backtrace/backtrace-api-v1.stderr b/tests/pass/backtrace/backtrace-api-v1.stderr index 826645ba3d..1ee5298f17 100644 --- a/tests/pass/backtrace/backtrace-api-v1.stderr +++ b/tests/pass/backtrace/backtrace-api-v1.stderr @@ -10,10 +10,6 @@ RUSTLIB/core/src/ops/function.rs:LL:CC (std::ops::function::impls::call_once) RUSTLIB/std/src/panicking.rs:LL:CC (std::panicking::r#try::do_call) RUSTLIB/std/src/panicking.rs:LL:CC (std::panicking::r#try) RUSTLIB/std/src/panic.rs:LL:CC (std::panic::catch_unwind) -RUSTLIB/std/src/rt.rs:LL:CC (std::rt::lang_start_internal::{closure#0}::{closure#0}) -RUSTLIB/std/src/panicking.rs:LL:CC (std::panicking::r#try::do_call) -RUSTLIB/std/src/panicking.rs:LL:CC (std::panicking::r#try) -RUSTLIB/std/src/panic.rs:LL:CC (std::panic::catch_unwind) RUSTLIB/std/src/rt.rs:LL:CC (std::rt::lang_start_internal::{closure#0}) RUSTLIB/std/src/panicking.rs:LL:CC (std::panicking::r#try::do_call) RUSTLIB/std/src/panicking.rs:LL:CC (std::panicking::r#try) diff --git a/tests/pass/backtrace/backtrace-global-alloc.stderr b/tests/pass/backtrace/backtrace-global-alloc.stderr index 30643bc670..26cdee18e3 100644 --- a/tests/pass/backtrace/backtrace-global-alloc.stderr +++ b/tests/pass/backtrace/backtrace-global-alloc.stderr @@ -14,7 +14,7 @@ at RUSTLIB/std/src/panicking.rs:LL:CC 7: std::panic::catch_unwind at RUSTLIB/std/src/panic.rs:LL:CC - 8: std::rt::lang_start_internal::{closure#0}::{closure#0} + 8: std::rt::lang_start_internal::{closure#0} at RUSTLIB/std/src/rt.rs:LL:CC 9: std::panicking::r#try::do_call at RUSTLIB/std/src/panicking.rs:LL:CC @@ -22,15 +22,7 @@ at RUSTLIB/std/src/panicking.rs:LL:CC 11: std::panic::catch_unwind at RUSTLIB/std/src/panic.rs:LL:CC - 12: std::rt::lang_start_internal::{closure#0} + 12: std::rt::lang_start_internal at RUSTLIB/std/src/rt.rs:LL:CC - 13: std::panicking::r#try::do_call - at RUSTLIB/std/src/panicking.rs:LL:CC - 14: std::panicking::r#try - at RUSTLIB/std/src/panicking.rs:LL:CC - 15: std::panic::catch_unwind - at RUSTLIB/std/src/panic.rs:LL:CC - 16: std::rt::lang_start_internal - at RUSTLIB/std/src/rt.rs:LL:CC - 17: std::rt::lang_start + 13: std::rt::lang_start at RUSTLIB/std/src/rt.rs:LL:CC diff --git a/tests/pass/backtrace/backtrace-std.stderr b/tests/pass/backtrace/backtrace-std.stderr index e04d2e561d..d89ae3837b 100644 --- a/tests/pass/backtrace/backtrace-std.stderr +++ b/tests/pass/backtrace/backtrace-std.stderr @@ -22,7 +22,7 @@ at RUSTLIB/std/src/panicking.rs:LL:CC 11: std::panic::catch_unwind at RUSTLIB/std/src/panic.rs:LL:CC - 12: std::rt::lang_start_internal::{closure#0}::{closure#0} + 12: std::rt::lang_start_internal::{closure#0} at RUSTLIB/std/src/rt.rs:LL:CC 13: std::panicking::r#try::do_call at RUSTLIB/std/src/panicking.rs:LL:CC @@ -30,15 +30,7 @@ at RUSTLIB/std/src/panicking.rs:LL:CC 15: std::panic::catch_unwind at RUSTLIB/std/src/panic.rs:LL:CC - 16: std::rt::lang_start_internal::{closure#0} + 16: std::rt::lang_start_internal at RUSTLIB/std/src/rt.rs:LL:CC - 17: std::panicking::r#try::do_call - at RUSTLIB/std/src/panicking.rs:LL:CC - 18: std::panicking::r#try - at RUSTLIB/std/src/panicking.rs:LL:CC - 19: std::panic::catch_unwind - at RUSTLIB/std/src/panic.rs:LL:CC - 20: std::rt::lang_start_internal - at RUSTLIB/std/src/rt.rs:LL:CC - 21: std::rt::lang_start + 17: std::rt::lang_start at RUSTLIB/std/src/rt.rs:LL:CC