Skip to content

Null and enum-discriminant runtime checks in debug builds #262

@nikomatsakis

Description

@nikomatsakis
Contributor
Metadata
Point of contact @1c3t3a
Team(s) compiler, lang, opsem
Goal document 2025h1/null-enum-discriminant-debug-checks

Summary

Add runtime checks to rustc that check for null pointers on pointer access and
invalid enum discriminants. Similar to integer overflow and pointer alignment
checks, this will only be enabled in debug builds.

Tasks and status

  • Discussion and moral support (lang, opsem Team)
    Implementation (@1c3t3a, @vabr-g)
    Standard reviews (compiler, opsem Team)

Activity

added this to the 2025h1 milestone on Feb 18, 2025
nikomatsakis

nikomatsakis commented on Feb 18, 2025

@nikomatsakis
ContributorAuthor

This issue is intended for status updates only.

For general questions or comments, please contact the owner(s) directly.

1c3t3a

1c3t3a commented on Feb 19, 2025

@1c3t3a
Member

Status update: The null-checks landed in rust#134424. Next up are the enum discriminant checks.

moved this to Project goals in Lang team featureson Feb 21, 2025
moved this to Project goal in Lang team featureson Mar 4, 2025
1c3t3a

1c3t3a commented on May 22, 2025

@1c3t3a
Member

Upps, giving another status update here:

Key developments: Landed an extension of the alignment check to include (mutable) borrows in rust#137940. Working on the enums check (no draft PR yet). Hope to open a PR by mid next week.

Blockers: None so far.

Help wanted: Happy to join forces on general checks and for advice what other UB would be great to check!! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Project goal

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @nikomatsakis@1c3t3a

      Issue actions

        Null and enum-discriminant runtime checks in debug builds · Issue #262 · rust-lang/rust-project-goals