-
Notifications
You must be signed in to change notification settings - Fork 55
[2025H1] Propose a null and alignment checks goal #162
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
Conversation
This mostly already exists? @saethlin added alignment checks in debug builds.
|
Oh I didn't see that! I could pivot this goal to something different in the area? E.g. around pointer arithmetics or checking enum discriminants? |
Aye, we already have checks for reads/writes through misaligned pointers and those have been on stable for a long time. The MIR transform that implements that could be extended to catch reads/writes to null but I suspect that will be very low-yield because on most hosted systems, that operation will fault anyway. In addition, the standard library has runtime checks for invalid pointer offsets starting in 1.83 which is stable today. I have prototyped something like invalid enum discriminants here: rust-lang/rust#121174. I'm sure the PR needs work to just get it to build. I was going for a more general approach of checking all niches not just enums, and that mostly emits a lot of checks for references being null, so maybe targeting enums only is the way. This goals PR seems well-intentioned, but I'm surprised to see it so disconnected from our current state. I would be happy to collaborate on sketching out a coherent story for our hodgepodge of runtime UB checks, but I'm a bit busy this week and next. |
I would like to collaborate on this! I send you a message on Zulip to discuss this further. For this goal: I'd love to pivot it to something helpful regarding runtime checks, so probably update it after having synced with @saethlin. |
I haven't heard anything here, I'm going to close this PR as the initial deadline for goals has passed and I don't think it's ready to merge -- please feel free to re-open once you've got a consensus plan in place (although time IS running out...). |
Rendered
cc: @tmandry, @RalfJung, @rcvalle