-
Notifications
You must be signed in to change notification settings - Fork 353
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
Stacked Borrows: too much raw pointer retagging hurts #1608
Comments
A possible fix might be to not retag after On the other hand, right now We could detect if the dereferenced pointer is raw or a reference... that seems to work for these cases, but it strikes me as rather ugly. |
So, to summarize, there are a bunch of alternatives, and we need to move away from the status quo. currently
your PR
not retag
unmentioned "alternative"
I'm not sure what the implications of the unmentioned alternative are, but we should probaby reject it explicitly |
The unmentioned alternative means that raw pointers maintain the tag of their parent reference. That has some far-reaching consequences. For example, it means after doing Worse, it means that when I do let ptr = raw_mut!(x.field);
x.field = 13; the raw pointer is still active, as it has the same tag as |
Thanks for the explanation! That makes sense |
Retagging: do not retag 'raw reborrows' When doing `&raw const (*raw_ptr).field`, we do not want any retagging; the original provenance should be fully preserved. Fixes rust-lang/miri#1608 Test added by rust-lang/miri#1614 Not sure whom to ask for review on this... `@oli-obk` can you have a look? Or maybe highfive makes a good choice.^^
Consider the following example (due to @ssomers):
Arguably, this is using
raw_mut!
correctly, but Miri flags this code as UB when using-Zmiri-track-raw-pointers
. The problem is that atptr::raw_mut!((*whole).part)
, a raw retag happens, which generates a fresh tag forpart
that is only valid for the memory of thepart
field, not for theextra
field.The text was updated successfully, but these errors were encountered: