-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Launch a non-unwinding panic for misaligned pointer deref #112599
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -166,14 +166,15 @@ fn panic_bounds_check(index: usize, len: usize) -> ! { | |
#[cfg_attr(not(feature = "panic_immediate_abort"), inline(never))] | ||
#[track_caller] | ||
#[lang = "panic_misaligned_pointer_dereference"] // needed by codegen for panic on misaligned pointer deref | ||
#[rustc_nounwind] // `CheckAlignment` MIR pass requires this function to never unwind | ||
fn panic_misaligned_pointer_dereference(required: usize, found: usize) -> ! { | ||
if cfg!(feature = "panic_immediate_abort") { | ||
super::intrinsics::abort() | ||
} | ||
|
||
panic!( | ||
panic_nounwind_fmt(format_args!( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should also make this function I wouldn't worry about non-local dependency that you mentioned at #112403 (comment), since this is a lang item and it's expected that lang item may need special guarantees. A |
||
"misaligned pointer dereference: address must be a multiple of {required:#x} but is {found:#x}" | ||
) | ||
)) | ||
} | ||
|
||
/// Panic because we cannot unwind out of a function. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be good to mention
panic_misaligned_pointer_dereference
here so one can grep for what that symbol is. (I was not aware/forgot that differentAssertKind
dispatch to completely different code on assertion failure.)