-
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 copy_from_slice #58810
Fix copy_from_slice #58810
Conversation
There is no guarantee that the slices are not overlapping.
r? @dtolnay (rust_highfive has picked a reviewer for you, use r? to override) |
r? @RalfJung |
I'd like to add a test, but I'm not sure where. |
A shared slice may never overlap with a mutably borrowed one. So this change does not seem right to me. |
Sorry, I may have gone a bit fast, my train was about to leave.
If the caller is unsafe, it's possible, no? But in that case, who bears the
responsibility?
In our case, the caller was vector.clone(), if I remember correctly. In
that case, if I can read the code correctly, it means that src is the
previous vector, and dst is the one we're creating. It seems weird that the
two overlap. Maybe the assertion is badly written, but I just reviewed it
and it doesn't seem wrong, or overly strict.
…On Thu, Feb 28, 2019, 16:02 Ralf Jung ***@***.***> wrote:
A shared slice may never overlap with a mutably borrowed one. So this
change does not seem right to me.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#58810 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAwn2SpiE8pj1bZXkbneiS40bE6M3j5gks5vR-9zgaJpZM4bW_me>
.
On Thu, Feb 28, 2019, 16:02 Ralf Jung ***@***.***> wrote:
A shared slice may never overlap with a mutably borrowed one. So this
change does not seem right to me.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#58810 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAwn2SpiE8pj1bZXkbneiS40bE6M3j5gks5vR-9zgaJpZM4bW_me>
.
|
The caller. You must not create such overlapping references, period -- even if you don't use them, that's already UB. |
ping from triage @nitnelave @RalfJung any updates on this? |
Sorry, I need to debug this, but it's trickier than expected (and I didn't have time recently). I'll try to have another swing at it some time this week. |
sure @nitnelave no issues :) |
I think this PR should be closed. The change is incorrect (or rather, unnecessary: we may assume here that the slices don't alias, and there is nothing gained by using |
fair enough, I'll open a new one when I have a better fix :) |
There is no guarantee that the slices are not overlapping.
This was discovered due to #58783