-
Notifications
You must be signed in to change notification settings - Fork 1
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
Meeting Proposal: Valid uses of addr_of! (and requirements of places) #9
Comments
I think this should be slightly broader -- basically this is about when exactly which properties of a place are required to avoid UB. Currently we have "whenever a place is constructed, it must be aligned and dereferenceable". That's also what Miri implements. In MiniRust we have "arbitrary places can be constructed; when doing a place projection, it must be inbounds (same rules as I'm happy to help draft the discussion document. |
Yeah we should definitely work together. I'll start something then we can iterate on it together. But mostly here I'm just saving a link to this very interesting footnote for myself: rust-lang/rust#112504 (comment) |
I realized we don't even have a UCG issue for the "place validity invariant", so here is one: rust-lang/unsafe-code-guidelines#418. That's basically what we want to resolve in this meeting, I think. |
I've started a writeup here, but it's only about my questions about |
Summary: There was some concern that
We agreed someone should make a PR against the reference to reflect this change, FCP'd by the team. We don't have anyone assigned to that task yet. |
I think there are more tasks than that? Keeping this list more for myself than anything:
|
I can take doing the |
Right there's a bunch of follow-ups to do. I can take care of Miri. FWIW I updated MiniRust to do the dereferenceable+aligned check on references but not raw pointers. |
The reference and Miri are updated. :) From the todo list above, we still have
|
Yep. Now that the reference is updated, I can do that. |
Yeah, I'll reshape that PR to match what is checked elsewhere. |
All the action items tracked above have PRs on their way. So I don't think we need to still keep this issue here open. Glad to have this long-standing open issue finally fully resolved. :) |
Summary
The implementation of
addr_of!
is just:Then the documentation for
ptr::addr_of!
says:The first paragraph of the documentation suggests that
addr_of!
is useful for creating misaligned pointers. Then the second paragraph warns about "all the usual rules", which are not defined anywhere. So reading this documentation, one can come away with either impression about whether this program is well-defined or not:Do "the usual rules" forbid the misaligned dereference inside of
addr_of!
? Or isaddr_of!
exempted because that's the whole reason it exists?The goal of this meeting is to decide if we are able to bless this use of
addr_of!
, whether we probably need it to be UB, or if we wish to delay this decision. If we wish to delay this decision, then we also have the goal of deciding what guidance we should offer to our users in the meantime.Reading
HackMD: https://hackmd.io/YjSceBPISBiGwsiqt9cDdw
Comment policy
These issues are meant to be used as an "announcements channel" regarding the proposal, and not as a
place to discuss the technical details. Feel free to subscribe to updates. We'll post comments when
reviewing the proposal in meetings or making a scheduling decision. In the meantime, if you have
questions or ideas, ping the proposers on Zulip (or elsewhere).
The text was updated successfully, but these errors were encountered: