-
-
Notifications
You must be signed in to change notification settings - Fork 14.3k
miri/const eval: support MaybeDangling
#150446
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
base: main
Are you sure you want to change the base?
Conversation
This comment has been minimized.
This comment has been minimized.
96d2a1d to
72213c3
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
This comment has been minimized.
This comment has been minimized.
72213c3 to
0d9e008
Compare
This comment has been minimized.
This comment has been minimized.
0d9e008 to
ae69218
Compare
|
The job Click to see the possible cause of the failure (guessed by this bot) |
| let inner = self.ecx.project_field(val, FieldIdx::ZERO)?; | ||
| self.visit_value(&inner)?; | ||
|
|
||
| self.may_dangle = could_dangle; |
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.
Is it intentional that this line could be skipped if the previous lines produce Err?
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.
I think that's fine. If this returns Err UB has been detected, so there is no way to continue execution anyway. See also similar pattern here, in existing code: https://github.com/WaffleLapkin/rust/blob/ae692187fd93e2aa68ed7cc6ba07cdeaee69304e/src/tools/miri/src/borrow_tracker/stacked_borrows/mod.rs#L977-L979
| let in_field = mem::replace(&mut self.in_field, true); // remember and restore old value | ||
| let may_dangle = mem::replace(&mut self.may_dangle, true); // remember and restore old value | ||
| self.walk_value(place)?; | ||
| self.may_dangle = may_dangle; |
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.
Same thing here
|
Does this have insta-stable behavior change for ManuallyDrop in consteval? |
|
It should only affect the behavior of code that still has UB until |
|
It is very import that we land #150447 before landing this, to avoid a situation where we generate LLVM IR with UB but Miri reports no UB. |
| // even if field retagging is not enabled. *shrug*) | ||
| self.walk_value(place)?; | ||
| } | ||
| ty::Adt(adt, _) if adt.is_maybe_dangling() => { |
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.
I think we can just entirely skip traversing the references inside MaybeDangling? For the aliasing model that should just be a complete NOP.
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.
Tree Borrows will need the same patch.
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.
Please put this test in https://github.com/rust-lang/miri/tree/master/tests/pass/both_borrows and call it maybe_dangling.rs. Also make sure it runs under both SB and TB, like the other tests in that folder.
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.
Also, probably better to directly test MaybeDangling instead of just indirectly via ManuallyDrop?
And finally, please add "fail" tests to ensure we still catch null and unaligned references.
r? RalfJung