Skip to content
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

Tracking issue for release notes of #134424: Insert null checks for pointer dereferences when debug assertions are enabled #136295

Open
1 of 3 tasks
rustbot opened this issue Jan 30, 2025 · 3 comments
Labels
relnotes Marks issues that should be documented in the release notes of the next release. relnotes-tracking-issue Marks issues tracking what text to put in release notes. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-opsem Relevant to the opsem team
Milestone

Comments

@rustbot
Copy link
Collaborator

rustbot commented Jan 30, 2025

This issue tracks the release notes text for #134424.

Steps

  • Proposed text is drafted by PR author (or team) making the noteworthy change.
  • Issue is nominated for release team review of clarity for wider audience.
  • Release team includes text in release notes/blog posts.

Release notes text

The responsible team for the underlying change should edit this section to replace the automatically generated link with a succinct description of what changed, drawing upon text proposed by the author (either in discussion or through direct editing).

# Compiler
- [Debug-assert that raw pointers are non-null on access.](https://github.com/rust-lang/rust/pull/134424)

Tip

Use the previous releases categories to help choose which one(s) to use.
The category will be de-duplicated with all the other ones by the release team.

More than one section can be included if needed.

Release blog section

If the change is notable enough for inclusion in the blog post, the responsible team should add content to this section.
Otherwise leave it empty.

cc @1c3t3a, @saethlin -- origin issue/PR authors and assignees for starting to draft text

@rustbot rustbot added relnotes Marks issues that should be documented in the release notes of the next release. relnotes-tracking-issue Marks issues tracking what text to put in release notes. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Jan 30, 2025
@rustbot rustbot added this to the 1.86.0 milestone Jan 31, 2025
@saethlin saethlin added T-opsem Relevant to the opsem team and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Feb 1, 2025
@saethlin
Copy link
Member

saethlin commented Feb 1, 2025

I don't think there is a terse and accurate way to describe the new checks. The existing release notes are probably fine? But I think this merits a better description, probably a small section in the blog post:

The MIR pass called CheckNull will now insert checks that a pointer is not null upon non-zero-sized reads and writes through the pointer are done, and also when the pointer is reborrowed into a reference. For example, the following code will now produce a non-unwinding panic:

let _x = *std::ptr::null::<u8>();
let _x = &*std::ptr::null::<u8>();

Trivial examples like this have produced a warning since Rust 1.53.0, the new runtime check will detect these scenarios regardless of complexity.

@Mark-Simulacrum
Copy link
Member

A few questions:

  • Did you mean to say reads and writes? I think both of those lines don't do any writes, right?
  • Does this also include other sources of reads (e.g., .read(), .read_unaligned())?

I rephrased the relnotes text as "Debug-assert that raw pointers are non-null on access" which is a bit more succinct and I think accurate?

@saethlin
Copy link
Member

saethlin commented Feb 1, 2025

Yes, reads and writes. Edited.

No, those functions do not have any new checks, and in fact have no checks at all because their MIR is from the precompiled std. In addition, assert_unsafe_precondition is also off in ptr::read and ptr:::write specifically because in them the checks impose measurable compile time overhead because of how widely they are used in the standard library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
relnotes Marks issues that should be documented in the release notes of the next release. relnotes-tracking-issue Marks issues tracking what text to put in release notes. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-opsem Relevant to the opsem team
Projects
None yet
Development

No branches or pull requests

3 participants