Skip to content

Commit 8dbf6f5

Browse files
Rollup merge of rust-lang#146118 - RalfJung:miri-abort, r=joboet
improve process::abort rendering in Miri backtraces Also, avoid using the `sys` function directly in the panic machinery -- that seems like an unnecessary layering violation.
2 parents d4a6bce + edddb2d commit 8dbf6f5

File tree

4 files changed

+5
-2
lines changed

4 files changed

+5
-2
lines changed

std/src/panicking.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,7 @@ fn panic_with_hook(
819819
rtprintpanic!("aborting due to panic at {location}:\n{payload}\n");
820820
}
821821
}
822-
crate::sys::abort_internal();
822+
crate::process::abort();
823823
}
824824

825825
match *HOOK.read().unwrap_or_else(PoisonError::into_inner) {
@@ -853,7 +853,7 @@ fn panic_with_hook(
853853
// through a nounwind function (e.g. extern "C") then we cannot continue
854854
// unwinding and have to abort immediately.
855855
rtprintpanic!("thread caused non-unwinding panic. aborting.\n");
856-
crate::sys::abort_internal();
856+
crate::process::abort();
857857
}
858858

859859
rust_panic(payload)

std/src/process.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2495,6 +2495,7 @@ pub fn exit(code: i32) -> ! {
24952495
#[stable(feature = "process_abort", since = "1.17.0")]
24962496
#[cold]
24972497
#[cfg_attr(not(test), rustc_diagnostic_item = "process_abort")]
2498+
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
24982499
pub fn abort() -> ! {
24992500
crate::sys::abort_internal();
25002501
}

std/src/sys/pal/unix/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,7 @@ pub fn cvt_nz(error: libc::c_int) -> crate::io::Result<()> {
364364
// multithreaded C program. It is much less severe for Rust, because Rust
365365
// stdlib doesn't use libc stdio buffering. In a typical Rust program, which
366366
// does not use C stdio, even a buggy libc::abort() is, in fact, safe.
367+
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
367368
pub fn abort_internal() -> ! {
368369
unsafe { libc::abort() }
369370
}

std/src/sys/pal/windows/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@ pub fn abort_internal() -> ! {
356356
}
357357

358358
#[cfg(miri)]
359+
#[track_caller] // even without panics, this helps for Miri backtraces
359360
pub fn abort_internal() -> ! {
360361
crate::intrinsics::abort();
361362
}

0 commit comments

Comments
 (0)