-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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 #91306 by deriving all access from a single *mut T #91616
Conversation
(rust-highfive has picked a reviewer for you, use r? to override) |
@bors r+ rollup=never |
📌 Commit fd6c78c3112e43e262db2050bc16f5bbc0111362 has been approved by |
ae21d2a
to
5b02faf
Compare
This needs to be re-reviewed since the branch was updated. @bors r- |
@rustbot ready |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be good to squash commits as well.
I edited the PR description to mark this as auto-closing #91306 given the PR title. |
@Mark-Simulacrum I think you somehow reviewed an old commit? I'm never clear on how force-pushes interact with the review/comment timeline. In any case, I've squashed down so hopefully things won't be confusing anymore. |
5b02faf
to
35cf0fe
Compare
@rustbot ready |
Most of these problems originate in use of get_unchecked_mut. When calling ptr::copy_nonoverlapping, using get_unchecked_mut for both arguments causes the borrow created to make the second pointer to invalid the first. The pairs of identical MaybeUninit::slice_as_mut_ptr calls similarly invalidate each other. There was also a similar borrow invalidation problem with the use of slice::get_unchecked_mut to derive the pointer for the CopyOnDrop.
c41bc74
to
3a0fa03
Compare
@bors r+ |
📌 Commit 3a0fa03 has been approved by |
☀️ Test successful - checks-actions |
Finished benchmarking commit (5531927): comparison url. Summary: This change led to very large relevant mixed results 🤷 in compiler performance.
If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. Next Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression |
This seems likely to be noise as a result of the issue tracked in rust-lang/rustc-perf#1126 -- marking as triaged, not something we should address directly. @rustbot label +perf-regression-triaged |
Fixes #91306.
The previous code is invalid because the first argument to
copy_nonoverlapping
is invalidated by the mutable borrow taken out to construct the second argument.I believe this patch fixes that, and this code should now pass Miri with
-Ztag-raw-pointers
,but I'm currently stuck trying to run my reproducer with a this patched version of the standard library (alternatively, running Miri on the standard library tests itself would suffice).Ralf walked me through this on Zulip.I've also added fixes for 7 more problems other than those I reported. Most of them are easy to hit by calling sort_unstable on random arrays. I don't have reproducers for every change, but they seem pretty clear-cut to me. But I did only start learning stacked borrows 2 days ago so that might be a large dash of Dunning-Kruger.