diff options
| author | Ralf Jung <post@ralfj.de> | 2025-09-02 12:09:05 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2025-09-02 12:19:06 +0200 |
| commit | a6c0519faef6512aff1ee1a1fe2bf2556fe2d642 (patch) | |
| tree | e9f7ecad1de8679eee1b92a8b96ae47dbfa46a2d /library/std/src | |
| parent | 05abce5d058db0de3abd10f32f1a442d0f699b30 (diff) | |
| download | rust-a6c0519faef6512aff1ee1a1fe2bf2556fe2d642.tar.gz rust-a6c0519faef6512aff1ee1a1fe2bf2556fe2d642.zip | |
improve process::abort rendering in Miri backtraces
Diffstat (limited to 'library/std/src')
| -rw-r--r-- | library/std/src/panicking.rs | 4 | ||||
| -rw-r--r-- | library/std/src/process.rs | 1 | ||||
| -rw-r--r-- | library/std/src/sys/pal/unix/mod.rs | 1 | ||||
| -rw-r--r-- | library/std/src/sys/pal/windows/mod.rs | 1 |
4 files changed, 5 insertions, 2 deletions
diff --git a/library/std/src/panicking.rs b/library/std/src/panicking.rs index 87a3fc80dfa..8b7282c51d1 100644 --- a/library/std/src/panicking.rs +++ b/library/std/src/panicking.rs @@ -819,7 +819,7 @@ fn panic_with_hook( rtprintpanic!("aborting due to panic at {location}:\n{payload}\n"); } } - crate::sys::abort_internal(); + crate::process::abort(); } match *HOOK.read().unwrap_or_else(PoisonError::into_inner) { @@ -853,7 +853,7 @@ fn panic_with_hook( // through a nounwind function (e.g. extern "C") then we cannot continue // unwinding and have to abort immediately. rtprintpanic!("thread caused non-unwinding panic. aborting.\n"); - crate::sys::abort_internal(); + crate::process::abort(); } rust_panic(payload) diff --git a/library/std/src/process.rs b/library/std/src/process.rs index 373584d0117..48265de90c4 100644 --- a/library/std/src/process.rs +++ b/library/std/src/process.rs @@ -2495,6 +2495,7 @@ pub fn exit(code: i32) -> ! { #[stable(feature = "process_abort", since = "1.17.0")] #[cold] #[cfg_attr(not(test), rustc_diagnostic_item = "process_abort")] +#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces pub fn abort() -> ! { crate::sys::abort_internal(); } diff --git a/library/std/src/sys/pal/unix/mod.rs b/library/std/src/sys/pal/unix/mod.rs index 400128acf12..ac5c823a1bf 100644 --- a/library/std/src/sys/pal/unix/mod.rs +++ b/library/std/src/sys/pal/unix/mod.rs @@ -364,6 +364,7 @@ pub fn cvt_nz(error: libc::c_int) -> crate::io::Result<()> { // multithreaded C program. It is much less severe for Rust, because Rust // stdlib doesn't use libc stdio buffering. In a typical Rust program, which // does not use C stdio, even a buggy libc::abort() is, in fact, safe. +#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces pub fn abort_internal() -> ! { unsafe { libc::abort() } } diff --git a/library/std/src/sys/pal/windows/mod.rs b/library/std/src/sys/pal/windows/mod.rs index 10ad4541bed..3b6a86cbc8f 100644 --- a/library/std/src/sys/pal/windows/mod.rs +++ b/library/std/src/sys/pal/windows/mod.rs @@ -356,6 +356,7 @@ pub fn abort_internal() -> ! { } #[cfg(miri)] +#[track_caller] // even without panics, this helps for Miri backtraces pub fn abort_internal() -> ! { crate::intrinsics::abort(); } |
