Skip to content

Commit dc86e79

Browse files
committed
Launch a non-unwinding panic for misaligned pointer deref
1 parent 98d72cf commit dc86e79

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)