Skip to content

Commit 6b89333

Browse files
committed
Auto merge of #112599 - saethlin:cleaner-panics, r=thomcc
Launch a non-unwinding panic for misaligned pointer deref This panic already never unwinds, but that's only because it always hits the unwind guard that's created by our `UnwindAction::Terminate`. Hitting the unwind guard generates a huge double-panic backtrace. Now we generate a normal-looking panic message when this check is hit. r? `@thomcc`
2 parents 3a7c906 + dc86e79 commit 6b89333

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

core/src/panicking.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,14 +166,15 @@ fn panic_bounds_check(index: usize, len: usize) -> ! {
166166
#[cfg_attr(not(feature = "panic_immediate_abort"), inline(never))]
167167
#[track_caller]
168168
#[lang = "panic_misaligned_pointer_dereference"] // needed by codegen for panic on misaligned pointer deref
169+
#[rustc_nounwind] // `CheckAlignment` MIR pass requires this function to never unwind
169170
fn panic_misaligned_pointer_dereference(required: usize, found: usize) -> ! {
170171
if cfg!(feature = "panic_immediate_abort") {
171172
super::intrinsics::abort()
172173
}
173174

174-
panic!(
175+
panic_nounwind_fmt(format_args!(
175176
"misaligned pointer dereference: address must be a multiple of {required:#x} but is {found:#x}"
176-
)
177+
))
177178
}
178179

179180
/// Panic because we cannot unwind out of a function.

0 commit comments

Comments
 (0)