-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Fix UB in transmute #34181
Fix UB in transmute #34181
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @brson (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
This is really tricky code and seems to have more problems than just transmuting |
@gmorenz So this change by itself doesn't fix much, borrowing I think we can defer the problem of replacing |
In other words, yes, |
@eddyb I've updated this to use |
@bors r+ Thank you! @gmorenz It's arguably not always UB, but it's really easy to misuse, and some strict memory models might make a lot of possible uses of To build a proper wrapper around it, you want to have an |
📌 Commit 80d2956 has been approved by |
⌛ Testing commit 80d2956 with merge 49829f3... |
💔 Test failed - auto-linux-64-opt-mir |
@alexcrichton Are there known valgrind issues around such globals? Should I hunt for codegen bugs? |
Hm not that I know of, that does look suspicious though... |
Sorry for letting this sit for this long, let's try again (just in case it was transient or a fixed MIR regression). @bors retry |
⌛ Testing commit 80d2956 with merge b15e775... |
💔 Test failed - auto-linux-64-opt-mir |
I honestly have no idea how this goes wrong. |
I also have no idea what the problem is, I think (though I'm not an expert) that the current set of optimizations doesn't take advantage of anything that might break the current code so merging this PR isn't high priority (from my point of view at least). |
☔ The latest upstream changes (presumably #36807) made this pull request unmergeable. Please resolve the merge conflicts. |
Closing due to inactivity, but feel free to resubmit with a rebase! |
The current code mutates through a
&
reference, this fixed that.We could remove
get_global_ptr
andtransmute
entirely by using#![feature(drop_types_in_const)]
, I'm not sure if this would be preferred.