From c49f592b694d32d9c101e2b946fbfcbd9d845939 Mon Sep 17 00:00:00 2001 From: Alan Egerton Date: Tue, 27 Jan 2026 13:26:25 +0000 Subject: [PATCH 1/3] Fix short backtraces from stripped executables Locate the beginning and ending frames for short backtraces by address in addition to symbol name, so that they work even when symbols have been stripped from the executable. We need to retain matching by symbol name for the time being, because rustc (and some associated ui tests) rely upon it to have ICE backtraces abbreviated. They can be updated once this commit lands in beta/stage0. --- library/std/src/backtrace.rs | 10 ++ library/std/src/sys/backtrace.rs | 93 +++++++++++++------ .../ui/panics/short-backtrace-in-stripped.rs | 18 ++++ .../short-backtrace-in-stripped.run.stderr | 9 ++ 4 files changed, 103 insertions(+), 27 deletions(-) create mode 100644 tests/ui/panics/short-backtrace-in-stripped.rs create mode 100644 tests/ui/panics/short-backtrace-in-stripped.run.stderr diff --git a/library/std/src/backtrace.rs b/library/std/src/backtrace.rs index 99724e29e02b2..c4a40d9e33034 100644 --- a/library/std/src/backtrace.rs +++ b/library/std/src/backtrace.rs @@ -94,6 +94,16 @@ use crate::panic::UnwindSafe; use crate::sync::LazyLock; use crate::sync::atomic::Ordering::Relaxed; use crate::sync::atomic::{Atomic, AtomicU8}; +#[unstable( + feature = "short_backtrace_controls", + reason = "to control abbreviation of backtraces", + issue = "none" +)] +#[doc(hidden)] +pub use crate::sys::backtrace::{ + __rust_begin_short_backtrace as resume_short_backtrace, + __rust_end_short_backtrace as pause_short_backtrace, +}; use crate::sys::backtrace::{lock, output_filename, set_image_base}; use crate::{env, fmt}; diff --git a/library/std/src/sys/backtrace.rs b/library/std/src/sys/backtrace.rs index 858a95882b39f..251cb49be356b 100644 --- a/library/std/src/sys/backtrace.rs +++ b/library/std/src/sys/backtrace.rs @@ -4,6 +4,7 @@ use crate::backtrace_rs::{self, BacktraceFmt, BytesOrWideString, PrintFmt}; use crate::borrow::Cow; use crate::io::prelude::*; +use crate::mem::{ManuallyDrop, MaybeUninit}; use crate::path::{self, Path, PathBuf}; use crate::sync::{Mutex, MutexGuard, PoisonError}; use crate::{env, fmt, io}; @@ -81,12 +82,26 @@ unsafe fn _print_fmt(fmt: &mut fmt::Formatter<'_>, print_fmt: PrintFmt) -> fmt:: let frame_ip = frame.ip(); res = writeln!(bt_fmt.formatter(), "{idx:4}: {frame_ip:HEX_WIDTH$?}"); } else { + // `call_with_end_short_backtrace_marker` means we are done hiding symbols + // for now. Print until we see `call_with_begin_short_backtrace_marker`. + if print_fmt == PrintFmt::Short { + let sym = frame.symbol_address(); + if sym == call_with_end_short_backtrace_marker as _ { + print = true; + return true; + } else if print && sym == call_with_begin_short_backtrace_marker as _ { + print = false; + return true; + } + } + let mut hit = false; backtrace_rs::resolve_frame_unsynchronized(frame, |symbol| { hit = true; - // `__rust_end_short_backtrace` means we are done hiding symbols - // for now. Print until we see `__rust_begin_short_backtrace`. + // Hide `__rust_[begin|end]_short_backtrace` frames from short backtraces. + // Unfortunately these generic functions have to be matched by name, as we do + // not know their generic parameters. if print_fmt == PrintFmt::Short { if let Some(sym) = symbol.name().and_then(|s| s.as_str()) { if sym.contains("__rust_end_short_backtrace") { @@ -155,36 +170,60 @@ unsafe fn _print_fmt(fmt: &mut fmt::Formatter<'_>, print_fmt: PrintFmt) -> fmt:: Ok(()) } -/// Fixed frame used to clean the backtrace with `RUST_BACKTRACE=1`. Note that -/// this is only inline(never) when backtraces in std are enabled, otherwise -/// it's fine to optimize away. -#[cfg_attr(feature = "backtrace", inline(never))] -pub fn __rust_begin_short_backtrace(f: F) -> T -where - F: FnOnce() -> T, -{ - let result = f(); +macro_rules! short_backtrace_controls { + ($($adapter:ident => $marker:ident($unique:literal)),* $(,)?) => {$( + /// Fixed frame used to clean the backtrace with `RUST_BACKTRACE=1`. Note that + /// this is only inline(never) when backtraces in std are enabled, otherwise + /// it's fine to optimize away. + /// + /// It is guaranteed that `f` will be called exactly once, and `unsafe` code may + /// rely on this to be the case. + #[cfg_attr(feature = "backtrace", inline(never))] + fn $marker(f: &mut dyn FnMut()) { + f(); + + // (Try to) prevent both Identical Code Folding (which might merge the different + // versions of this function, giving them the same address) and Tail Call Optimisation + // (which could remove their frames from the call stack). + crate::hint::black_box($unique); + } - // prevent this frame from being tail-call optimised away - crate::hint::black_box(()); + /// Invokes `$marker` with an adaptation of `f`, returning its result. + /// This is a more ergonomic interface for placing the marker frame on the stack than + /// the `$marker` function itself. It can be inlined without problem. + #[doc(hidden)] + #[unstable( + feature = "short_backtrace_controls", + reason = "to control abbreviation of backtraces", + issue = "none" + )] + #[inline(always)] + pub fn $adapter(f: F) -> T + where + F: FnOnce() -> T, + { + let mut result = MaybeUninit::::uninit(); + let mut f = ManuallyDrop::new(f); - result -} + let mut adapted = || { + // SAFETY: `adapted` is called exactly once, by `$marker`; + // and the `ManuallyDrop` is not otherwise used again. + let f = unsafe { ManuallyDrop::take(&mut f) }; + result.write(f()); + }; -/// Fixed frame used to clean the backtrace with `RUST_BACKTRACE=1`. Note that -/// this is only inline(never) when backtraces in std are enabled, otherwise -/// it's fine to optimize away. -#[cfg_attr(feature = "backtrace", inline(never))] -pub fn __rust_end_short_backtrace(f: F) -> T -where - F: FnOnce() -> T, -{ - let result = f(); + $marker(&mut adapted); - // prevent this frame from being tail-call optimised away - crate::hint::black_box(()); + // SAFETY: `$marker` guaranteed that it would call `adapted`, which + // initialized `result`. + unsafe { result.assume_init() } + } + )*}; +} - result +short_backtrace_controls! { + __rust_begin_short_backtrace => call_with_begin_short_backtrace_marker(0), + __rust_end_short_backtrace => call_with_end_short_backtrace_marker(1), } /// Prints the filename of the backtrace frame. diff --git a/tests/ui/panics/short-backtrace-in-stripped.rs b/tests/ui/panics/short-backtrace-in-stripped.rs new file mode 100644 index 0000000000000..27d72254e4485 --- /dev/null +++ b/tests/ui/panics/short-backtrace-in-stripped.rs @@ -0,0 +1,18 @@ +//! Short backtraces should still be emitted from stripped binaries. +//! Regression test for https://github.com/rust-lang/rust/issues/147846 +// +//@ compile-flags: -Cstrip=symbols +//@ exec-env: RUST_BACKTRACE=1 +//@ run-fail +//@ check-run-results +// +// Name mangling scheme differences +//@ normalize-stderr: "begin_panic::<&str>" -> "begin_panic" +// +// macOS with `rust.debuginfo-level = "line-tables-only"` (#133997) +//@ normalize-stderr: " begin_panic<&str>" -> " std::panicking::begin_panic" +// +// debuginfo +//@ normalize-stderr: "\n +at [^\n]+" -> "" + +fn main() { panic!(); } diff --git a/tests/ui/panics/short-backtrace-in-stripped.run.stderr b/tests/ui/panics/short-backtrace-in-stripped.run.stderr new file mode 100644 index 0000000000000..a2f4bd7a4d830 --- /dev/null +++ b/tests/ui/panics/short-backtrace-in-stripped.run.stderr @@ -0,0 +1,9 @@ + +thread 'main' ($TID) panicked at $DIR/short-backtrace-in-stripped.rs:18:13: +explicit panic +stack backtrace: + 0: std::panicking::begin_panic + 1: + 2: + 3: +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. From 36f1f0c92fefe3acc450502d0cdc09132f77c692 Mon Sep 17 00:00:00 2001 From: Alan Egerton Date: Fri, 30 Jan 2026 21:20:11 +0000 Subject: [PATCH 2/3] Bless miri tests The new short backtrace markers place three frames in backtraces: the marker initially invoked by downstream code (should be inlined into such downstream code); the type-erased marker at a known-address (detected by the backtrace printing code); and the type-restoring callback shim (into which the actual callback should also be inlined). This differs from the status-quo ante, where the backtrace markers placed only a single frame into backtraces. Whilst these additional frames should have negligible impact on runtime performance (not only are they called, by the language runtime, at most twice: once during start before invoking main and once upon panic, if any; but furthermore, due to the aforementioned inlining, optimized assembly should be very similar - the additional frames will mostly only arise from additional debug info), the expected outputs from some miri tests require updating to reflect these backtrace changes. --- .../fail/alloc/alloc_error_handler.stderr | 16 +++++++---- .../miri/tests/fail/panic/panic_abort1.stderr | 10 +++++-- .../miri/tests/fail/panic/panic_abort2.stderr | 10 +++++-- .../miri/tests/fail/panic/panic_abort3.stderr | 10 +++++-- .../miri/tests/fail/panic/panic_abort4.stderr | 10 +++++-- .../tests/fail/tail_calls/cc-mismatch.stderr | 28 +++++++++++-------- .../pass/backtrace/backtrace-api-v1.stderr | 4 ++- .../backtrace/backtrace-global-alloc.stderr | 28 +++++++++++-------- .../tests/pass/backtrace/backtrace-std.stderr | 28 +++++++++++-------- 9 files changed, 89 insertions(+), 55 deletions(-) diff --git a/src/tools/miri/tests/fail/alloc/alloc_error_handler.stderr b/src/tools/miri/tests/fail/alloc/alloc_error_handler.stderr index ed9b7ad18b0fa..40cd31563c229 100644 --- a/src/tools/miri/tests/fail/alloc/alloc_error_handler.stderr +++ b/src/tools/miri/tests/fail/alloc/alloc_error_handler.stderr @@ -10,17 +10,21 @@ LL | crate::process::abort() = note: stack backtrace: 0: std::alloc::rust_oom::{closure#0} at RUSTLIB/std/src/alloc.rs:LL:CC - 1: std::sys::backtrace::__rust_end_short_backtrace + 1: std::backtrace::__rust_end_short_backtrace::{closure#0} at RUSTLIB/std/src/sys/backtrace.rs:LL:CC - 2: std::alloc::rust_oom + 2: std::sys::backtrace::call_with_end_short_backtrace_marker + at RUSTLIB/std/src/sys/backtrace.rs:LL:CC + 3: std::backtrace::__rust_end_short_backtrace + at RUSTLIB/std/src/sys/backtrace.rs:LL:CC + 4: std::alloc::rust_oom at RUSTLIB/std/src/alloc.rs:LL:CC - 3: std::alloc::_::__rust_alloc_error_handler + 5: std::alloc::_::__rust_alloc_error_handler at RUSTLIB/std/src/alloc.rs:LL:CC - 4: std::alloc::handle_alloc_error::rt_error + 6: std::alloc::handle_alloc_error::rt_error at RUSTLIB/alloc/src/alloc.rs:LL:CC - 5: std::alloc::handle_alloc_error + 7: std::alloc::handle_alloc_error at RUSTLIB/alloc/src/alloc.rs:LL:CC - 6: main + 8: main at tests/fail/alloc/alloc_error_handler.rs:LL:CC note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace diff --git a/src/tools/miri/tests/fail/panic/panic_abort1.stderr b/src/tools/miri/tests/fail/panic/panic_abort1.stderr index 4135ceadc5397..dfab918cccee6 100644 --- a/src/tools/miri/tests/fail/panic/panic_abort1.stderr +++ b/src/tools/miri/tests/fail/panic/panic_abort1.stderr @@ -20,11 +20,15 @@ LL | crate::process::abort(); at RUSTLIB/std/src/panicking.rs:LL:CC 4: std::panicking::panic_handler::{closure#0} at RUSTLIB/std/src/panicking.rs:LL:CC - 5: std::sys::backtrace::__rust_end_short_backtrace + 5: std::backtrace::__rust_end_short_backtrace::{closure#0} at RUSTLIB/std/src/sys/backtrace.rs:LL:CC - 6: std::panicking::panic_handler + 6: std::sys::backtrace::call_with_end_short_backtrace_marker + at RUSTLIB/std/src/sys/backtrace.rs:LL:CC + 7: std::backtrace::__rust_end_short_backtrace + at RUSTLIB/std/src/sys/backtrace.rs:LL:CC + 8: std::panicking::panic_handler at RUSTLIB/std/src/panicking.rs:LL:CC - 7: main + 9: main at RUSTLIB/core/src/panic.rs:LL:CC note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace diff --git a/src/tools/miri/tests/fail/panic/panic_abort2.stderr b/src/tools/miri/tests/fail/panic/panic_abort2.stderr index 5b485604037ce..41d814f21e8cc 100644 --- a/src/tools/miri/tests/fail/panic/panic_abort2.stderr +++ b/src/tools/miri/tests/fail/panic/panic_abort2.stderr @@ -20,11 +20,15 @@ LL | crate::process::abort(); at RUSTLIB/std/src/panicking.rs:LL:CC 4: std::panicking::panic_handler::{closure#0} at RUSTLIB/std/src/panicking.rs:LL:CC - 5: std::sys::backtrace::__rust_end_short_backtrace + 5: std::backtrace::__rust_end_short_backtrace::{closure#0} at RUSTLIB/std/src/sys/backtrace.rs:LL:CC - 6: std::panicking::panic_handler + 6: std::sys::backtrace::call_with_end_short_backtrace_marker + at RUSTLIB/std/src/sys/backtrace.rs:LL:CC + 7: std::backtrace::__rust_end_short_backtrace + at RUSTLIB/std/src/sys/backtrace.rs:LL:CC + 8: std::panicking::panic_handler at RUSTLIB/std/src/panicking.rs:LL:CC - 7: main + 9: main at RUSTLIB/core/src/panic.rs:LL:CC note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace diff --git a/src/tools/miri/tests/fail/panic/panic_abort3.stderr b/src/tools/miri/tests/fail/panic/panic_abort3.stderr index e4179f93f931c..1058afd155d73 100644 --- a/src/tools/miri/tests/fail/panic/panic_abort3.stderr +++ b/src/tools/miri/tests/fail/panic/panic_abort3.stderr @@ -20,11 +20,15 @@ LL | crate::process::abort(); at RUSTLIB/std/src/panicking.rs:LL:CC 4: std::panicking::panic_handler::{closure#0} at RUSTLIB/std/src/panicking.rs:LL:CC - 5: std::sys::backtrace::__rust_end_short_backtrace + 5: std::backtrace::__rust_end_short_backtrace::{closure#0} at RUSTLIB/std/src/sys/backtrace.rs:LL:CC - 6: std::panicking::panic_handler + 6: std::sys::backtrace::call_with_end_short_backtrace_marker + at RUSTLIB/std/src/sys/backtrace.rs:LL:CC + 7: std::backtrace::__rust_end_short_backtrace + at RUSTLIB/std/src/sys/backtrace.rs:LL:CC + 8: std::panicking::panic_handler at RUSTLIB/std/src/panicking.rs:LL:CC - 7: main + 9: main at RUSTLIB/core/src/panic.rs:LL:CC note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace diff --git a/src/tools/miri/tests/fail/panic/panic_abort4.stderr b/src/tools/miri/tests/fail/panic/panic_abort4.stderr index d2e50b87068f6..63d30c0f645a7 100644 --- a/src/tools/miri/tests/fail/panic/panic_abort4.stderr +++ b/src/tools/miri/tests/fail/panic/panic_abort4.stderr @@ -20,11 +20,15 @@ LL | crate::process::abort(); at RUSTLIB/std/src/panicking.rs:LL:CC 4: std::panicking::panic_handler::{closure#0} at RUSTLIB/std/src/panicking.rs:LL:CC - 5: std::sys::backtrace::__rust_end_short_backtrace + 5: std::backtrace::__rust_end_short_backtrace::{closure#0} at RUSTLIB/std/src/sys/backtrace.rs:LL:CC - 6: std::panicking::panic_handler + 6: std::sys::backtrace::call_with_end_short_backtrace_marker + at RUSTLIB/std/src/sys/backtrace.rs:LL:CC + 7: std::backtrace::__rust_end_short_backtrace + at RUSTLIB/std/src/sys/backtrace.rs:LL:CC + 8: std::panicking::panic_handler at RUSTLIB/std/src/panicking.rs:LL:CC - 7: main + 9: main at RUSTLIB/core/src/panic.rs:LL:CC note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace diff --git a/src/tools/miri/tests/fail/tail_calls/cc-mismatch.stderr b/src/tools/miri/tests/fail/tail_calls/cc-mismatch.stderr index c7e471f570c85..19b88f2893534 100644 --- a/src/tools/miri/tests/fail/tail_calls/cc-mismatch.stderr +++ b/src/tools/miri/tests/fail/tail_calls/cc-mismatch.stderr @@ -9,29 +9,33 @@ LL | extern "rust-call" fn call_once(self, args: Args) -> Self::Output; = note: stack backtrace: 0: >::call_once - shim(fn()) at RUSTLIB/core/src/ops/function.rs:LL:CC - 1: std::sys::backtrace::__rust_begin_short_backtrace + 1: std::backtrace::__rust_begin_short_backtrace::{closure#0} at RUSTLIB/std/src/sys/backtrace.rs:LL:CC - 2: std::rt::lang_start::{closure#0} + 2: std::sys::backtrace::call_with_begin_short_backtrace_marker + at RUSTLIB/std/src/sys/backtrace.rs:LL:CC + 3: std::backtrace::__rust_begin_short_backtrace + at RUSTLIB/std/src/sys/backtrace.rs:LL:CC + 4: std::rt::lang_start::{closure#0} at RUSTLIB/std/src/rt.rs:LL:CC - 3: std::ops::function::impls::call_once + 5: std::ops::function::impls::call_once at RUSTLIB/core/src/ops/function.rs:LL:CC - 4: std::panicking::catch_unwind::do_call + 6: std::panicking::catch_unwind::do_call at RUSTLIB/std/src/panicking.rs:LL:CC - 5: std::panicking::catch_unwind + 7: std::panicking::catch_unwind at RUSTLIB/std/src/panicking.rs:LL:CC - 6: std::panic::catch_unwind + 8: std::panic::catch_unwind at RUSTLIB/std/src/panic.rs:LL:CC - 7: std::rt::lang_start_internal::{closure#0} + 9: std::rt::lang_start_internal::{closure#0} at RUSTLIB/std/src/rt.rs:LL:CC - 8: std::panicking::catch_unwind::do_call + 10: std::panicking::catch_unwind::do_call at RUSTLIB/std/src/panicking.rs:LL:CC - 9: std::panicking::catch_unwind + 11: std::panicking::catch_unwind at RUSTLIB/std/src/panicking.rs:LL:CC - 10: std::panic::catch_unwind + 12: std::panic::catch_unwind at RUSTLIB/std/src/panic.rs:LL:CC - 11: std::rt::lang_start_internal + 13: std::rt::lang_start_internal at RUSTLIB/std/src/rt.rs:LL:CC - 12: std::rt::lang_start + 14: std::rt::lang_start at RUSTLIB/std/src/rt.rs:LL:CC error: aborting due to 1 previous error diff --git a/src/tools/miri/tests/pass/backtrace/backtrace-api-v1.stderr b/src/tools/miri/tests/pass/backtrace/backtrace-api-v1.stderr index 8e167dbadef6c..cda61055aab26 100644 --- a/src/tools/miri/tests/pass/backtrace/backtrace-api-v1.stderr +++ b/src/tools/miri/tests/pass/backtrace/backtrace-api-v1.stderr @@ -4,7 +4,9 @@ tests/pass/backtrace/backtrace-api-v1.rs:LL:CC (func_b) tests/pass/backtrace/backtrace-api-v1.rs:LL:CC (func_a) tests/pass/backtrace/backtrace-api-v1.rs:LL:CC (main) RUSTLIB/core/src/ops/function.rs:LL:CC (>::call_once - shim(fn())) -RUSTLIB/std/src/sys/backtrace.rs:LL:CC (std::sys::backtrace::__rust_begin_short_backtrace) +RUSTLIB/std/src/sys/backtrace.rs:LL:CC (std::backtrace::__rust_begin_short_backtrace::{closure#0}) +RUSTLIB/std/src/sys/backtrace.rs:LL:CC (std::sys::backtrace::call_with_begin_short_backtrace_marker) +RUSTLIB/std/src/sys/backtrace.rs:LL:CC (std::backtrace::__rust_begin_short_backtrace) RUSTLIB/std/src/rt.rs:LL:CC (std::rt::lang_start::{closure#0}) RUSTLIB/core/src/ops/function.rs:LL:CC (std::ops::function::impls::call_once) RUSTLIB/std/src/panicking.rs:LL:CC (std::panicking::catch_unwind::do_call) diff --git a/src/tools/miri/tests/pass/backtrace/backtrace-global-alloc.stderr b/src/tools/miri/tests/pass/backtrace/backtrace-global-alloc.stderr index b4ef3f76c20f7..e6bf486b9300b 100644 --- a/src/tools/miri/tests/pass/backtrace/backtrace-global-alloc.stderr +++ b/src/tools/miri/tests/pass/backtrace/backtrace-global-alloc.stderr @@ -2,27 +2,31 @@ at tests/pass/backtrace/backtrace-global-alloc.rs:LL:CC 1: >::call_once - shim(fn()) at RUSTLIB/core/src/ops/function.rs:LL:CC - 2: std::sys::backtrace::__rust_begin_short_backtrace + 2: std::backtrace::__rust_begin_short_backtrace::{closure#0} at RUSTLIB/std/src/sys/backtrace.rs:LL:CC - 3: std::rt::lang_start::{closure#0} + 3: std::sys::backtrace::call_with_begin_short_backtrace_marker + at RUSTLIB/std/src/sys/backtrace.rs:LL:CC + 4: std::backtrace::__rust_begin_short_backtrace + at RUSTLIB/std/src/sys/backtrace.rs:LL:CC + 5: std::rt::lang_start::{closure#0} at RUSTLIB/std/src/rt.rs:LL:CC - 4: std::ops::function::impls::call_once + 6: std::ops::function::impls::call_once at RUSTLIB/core/src/ops/function.rs:LL:CC - 5: std::panicking::catch_unwind::do_call + 7: std::panicking::catch_unwind::do_call at RUSTLIB/std/src/panicking.rs:LL:CC - 6: std::panicking::catch_unwind + 8: std::panicking::catch_unwind at RUSTLIB/std/src/panicking.rs:LL:CC - 7: std::panic::catch_unwind + 9: std::panic::catch_unwind at RUSTLIB/std/src/panic.rs:LL:CC - 8: std::rt::lang_start_internal::{closure#0} + 10: std::rt::lang_start_internal::{closure#0} at RUSTLIB/std/src/rt.rs:LL:CC - 9: std::panicking::catch_unwind::do_call + 11: std::panicking::catch_unwind::do_call at RUSTLIB/std/src/panicking.rs:LL:CC - 10: std::panicking::catch_unwind + 12: std::panicking::catch_unwind at RUSTLIB/std/src/panicking.rs:LL:CC - 11: std::panic::catch_unwind + 13: std::panic::catch_unwind at RUSTLIB/std/src/panic.rs:LL:CC - 12: std::rt::lang_start_internal + 14: std::rt::lang_start_internal at RUSTLIB/std/src/rt.rs:LL:CC - 13: std::rt::lang_start + 15: std::rt::lang_start at RUSTLIB/std/src/rt.rs:LL:CC diff --git a/src/tools/miri/tests/pass/backtrace/backtrace-std.stderr b/src/tools/miri/tests/pass/backtrace/backtrace-std.stderr index 706eacc70fd8d..60adff00c782d 100644 --- a/src/tools/miri/tests/pass/backtrace/backtrace-std.stderr +++ b/src/tools/miri/tests/pass/backtrace/backtrace-std.stderr @@ -10,27 +10,31 @@ at tests/pass/backtrace/backtrace-std.rs:LL:CC 5: >::call_once - shim(fn()) at RUSTLIB/core/src/ops/function.rs:LL:CC - 6: std::sys::backtrace::__rust_begin_short_backtrace + 6: std::backtrace::__rust_begin_short_backtrace::{closure#0} at RUSTLIB/std/src/sys/backtrace.rs:LL:CC - 7: std::rt::lang_start::{closure#0} + 7: std::sys::backtrace::call_with_begin_short_backtrace_marker + at RUSTLIB/std/src/sys/backtrace.rs:LL:CC + 8: std::backtrace::__rust_begin_short_backtrace + at RUSTLIB/std/src/sys/backtrace.rs:LL:CC + 9: std::rt::lang_start::{closure#0} at RUSTLIB/std/src/rt.rs:LL:CC - 8: std::ops::function::impls::call_once + 10: std::ops::function::impls::call_once at RUSTLIB/core/src/ops/function.rs:LL:CC - 9: std::panicking::catch_unwind::do_call + 11: std::panicking::catch_unwind::do_call at RUSTLIB/std/src/panicking.rs:LL:CC - 10: std::panicking::catch_unwind + 12: std::panicking::catch_unwind at RUSTLIB/std/src/panicking.rs:LL:CC - 11: std::panic::catch_unwind + 13: std::panic::catch_unwind at RUSTLIB/std/src/panic.rs:LL:CC - 12: std::rt::lang_start_internal::{closure#0} + 14: std::rt::lang_start_internal::{closure#0} at RUSTLIB/std/src/rt.rs:LL:CC - 13: std::panicking::catch_unwind::do_call + 15: std::panicking::catch_unwind::do_call at RUSTLIB/std/src/panicking.rs:LL:CC - 14: std::panicking::catch_unwind + 16: std::panicking::catch_unwind at RUSTLIB/std/src/panicking.rs:LL:CC - 15: std::panic::catch_unwind + 17: std::panic::catch_unwind at RUSTLIB/std/src/panic.rs:LL:CC - 16: std::rt::lang_start_internal + 18: std::rt::lang_start_internal at RUSTLIB/std/src/rt.rs:LL:CC - 17: std::rt::lang_start + 19: std::rt::lang_start at RUSTLIB/std/src/rt.rs:LL:CC From c8164c08f6cf2cca87a643904a2bd9b33c35f9c4 Mon Sep 17 00:00:00 2001 From: Alan Egerton Date: Tue, 27 Jan 2026 21:53:51 +0000 Subject: [PATCH 3/3] Use local label in naked function to avoid collisions This status-quo ante of this naked function test defined a label with the symbolic name `.L7`. However, changes to the stack could cause a collision with that same symbolic name being defined by compiler- generated code; therefore we use a local label instead to guarantee collision avoidance. --- tests/ui/c-variadic/naked.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/ui/c-variadic/naked.rs b/tests/ui/c-variadic/naked.rs index 73664206d9ced..61dfd316612a4 100644 --- a/tests/ui/c-variadic/naked.rs +++ b/tests/ui/c-variadic/naked.rs @@ -15,9 +15,9 @@ unsafe extern "sysv64" fn c_variadic_sysv64(_: ...) -> Data { " sub rsp, 96", " mov QWORD PTR [rsp-88], rdi", " test al, al", - " je .L7", + " je 0f", " movaps XMMWORD PTR [rsp-40], xmm0", - ".L7:", + "0:", " lea rax, [rsp+104]", " mov rcx, QWORD PTR [rsp-40]", " mov DWORD PTR [rsp-112], 0",