Skip to content

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

Closed
@rustbot

Description

@rustbot
Collaborator

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

Activity

added
relnotesMarks issues that should be documented in the release notes of the next release.
relnotes-tracking-issueMarks issues tracking what text to put in release notes.
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
T-libsRelevant to the library team, which will review and decide on the PR/issue.
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Jan 30, 2025
added this to the 1.86.0 milestone on Jan 31, 2025
added
T-opsemRelevant to the opsem team
and removed
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Feb 1, 2025
saethlin

saethlin commented on Feb 1, 2025

@saethlin
Member

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

Mark-Simulacrum commented on Feb 1, 2025

@Mark-Simulacrum
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

saethlin commented on Feb 1, 2025

@saethlin
Member

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-libsRelevant to the library team, which will review and decide on the PR/issue.T-opsemRelevant to the opsem teamrelnotesMarks issues that should be documented in the release notes of the next release.relnotes-tracking-issueMarks issues tracking what text to put in release notes.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @Mark-Simulacrum@saethlin@BoxyUwU@rustbot

        Issue actions

          Tracking issue for release notes of #134424: Insert null checks for pointer dereferences when debug assertions are enabled · Issue #136295 · rust-lang/rust