1
Fork 0
rust/library
bors aa4cfd0809 Auto merge of #134424 - 1c3t3a:null-checks, r=saethlin
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 inserts checks in the same places as the `CheckAlignment` pass and additionally
also inserts checks for `Borrows`, so code like
```rust
let ptr: *const u32 = std::ptr::null();
let val: &u32 = unsafe { &*ptr };
```
will have a check inserted on dereference. This is done because null references
are UB. The alignment check doesn't cover these places, because in `&(*ptr).field`,
the exact requirement is that the final reference must be aligned. This is something to
consider further enhancements of the alignment check.

For now this is implemented as a separate `MirPass`, to make it easy to disable
this check if necessary.

This is related to a 2025H1 project goal for better UB checks in debug
mode: https://github.com/rust-lang/rust-project-goals/pull/177.

r? `@saethlin`
2025-01-31 15:56:53 +00:00
..
alloc Rollup merge of #136215 - btj:patch-1, r=cuviper 2025-01-30 14:25:05 +11:00
backtrace@f8cc6ac9ac Bump backtrace to 0.3.75 2025-01-03 20:16:52 -08:00
core Auto merge of #134424 - 1c3t3a:null-checks, r=saethlin 2025-01-31 15:56:53 +00:00
coretests Stabilize const_black_box 2025-01-27 07:54:58 +00:00
panic_abort step cfg(bootstrap) 2024-07-28 14:46:29 -04:00
panic_unwind panic_unwind: add #![warn(unreachable_pub)] 2025-01-20 18:35:32 +01:00
portable-simd Bump stdarch 2024-12-24 19:00:57 +01:00
proc_macro proc_macro: add #![warn(unreachable_pub)] 2025-01-20 18:46:29 +01:00
profiler_builtins compiler & tools dependencies: 2024-12-17 17:41:00 +00:00
rtstartup rtstartup: add #![warn(unreachable_pub)] 2025-01-20 18:35:32 +01:00
rustc-std-workspace-alloc
rustc-std-workspace-core update rustc-std-workspace crates 2024-11-04 07:45:15 +01:00
rustc-std-workspace-std
std Rollup merge of #136288 - joshtriplett:would-you-could-you-with-some-locks--would-you-could-you-in-some-docs, r=m-ou-se 2025-01-30 20:47:09 +01:00
stdarch@684de0d6fe Bump stdarch 2024-12-24 19:00:57 +01:00
sysroot Make profiler_builtins an optional dependency of sysroot, not std 2024-10-17 22:08:36 +11:00
test Rollup merge of #135948 - bjorn3:update_emscripten_std_tests, r=Mark-Simulacrum 2025-01-25 23:27:00 -05:00
unwind Rollup merge of #131830 - hoodmane:emscripten-wasm-eh, r=workingjubilee 2025-01-06 22:04:13 -05:00
windows_targets Win: Add dbghelp to the list of import libraries 2024-09-06 21:21:49 +00:00
Cargo.lock Put all coretests in a separate crate 2025-01-26 10:26:36 +00:00
Cargo.toml Put all coretests in a separate crate 2025-01-26 10:26:36 +00:00