Skip to content

Commit 8196d26

Browse files
committed
Insert null checks for pointer dereferences when debug assertions are enabled
Similar to how the alignment is already checked, this adds a check for null pointer dereferences in debug mode. It is implemented similarly to the alignment check as a MirPass. This is related to a 2025H1 project goal for better UB checks in debug mode: rust-lang/rust-project-goals#177.
1 parent d473536 commit 8196d26

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

crates/hir-def/src/lang_item.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,7 @@ language_item_table! {
411411
PanicLocation, sym::panic_location, panic_location, Target::Struct, GenericRequirement::None;
412412
PanicImpl, sym::panic_impl, panic_impl, Target::Fn, GenericRequirement::None;
413413
PanicCannotUnwind, sym::panic_cannot_unwind, panic_cannot_unwind, Target::Fn, GenericRequirement::Exact(0);
414+
PanicNullPointerDereference, sym::panic_null_pointer_dereference, panic_null_pointer_dereference, Target::Fn, GenericRequirement::None;
414415
/// libstd panic entry point. Necessary for const eval to be able to catch it
415416
BeginPanic, sym::begin_panic, begin_panic_fn, Target::Fn, GenericRequirement::None;
416417

crates/intern/src/symbol/symbols.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ define_symbols! {
363363
panic_location,
364364
panic_misaligned_pointer_dereference,
365365
panic_nounwind,
366+
panic_null_pointer_dereference,
366367
panic,
367368
Param,
368369
parse,

0 commit comments

Comments
 (0)