-
Notifications
You must be signed in to change notification settings - Fork 413
Support retagging of wildcard references in tree borrows #4707
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
Support retagging of wildcard references in tree borrows #4707
Conversation
|
Thank you for contributing to Miri! A reviewer will take a look at your PR, typically within a week or two. |
This comment has been minimized.
This comment has been minimized.
99dacc6 to
52f2087
Compare
This comment has been minimized.
This comment has been minimized.
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.
Overall approach looks good. Here's a bunch of comments. :)
Please also add the 3 SB tests in this area: illegal_read/write_despite_exposed*.
|
|
||
| let state = perm.or_insert(node.default_location_state()); | ||
| #[cfg(feature = "expensive-consistency-checks")] | ||
| self.verify_wildcard_consistency(global); |
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.
We should only need this if a wildcard is involved in the access, right? I.e. if the tag is wildcard, or if there are multiple roots.
|
|
||
| /// Print extra text if the tag is exposed. | ||
| fn print_exposed(&self, exposed: bool) -> S { | ||
| if exposed { " Exposed" } else { "" } |
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.
| if exposed { " Exposed" } else { "" } | |
| if exposed { " (exposed)" } else { "" } |
| // We can still access both ref1, ref2. | ||
| assert_eq!(*ref2, 13); |
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.
Comment and code don't quite match... we can access both, after all.
You can just explain that this is technically UB we don't catch.
| // We should be able to access any of the references. | ||
| assert_eq!(*ref2, 13); |
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.
Again this doesn't quite test what the comment says.
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 explain in the comment that this tests the max_local_tag logic.
|
Reminder, once the PR becomes ready for a review, use |
| }; | ||
| // Afterwards we check all tags in arbitrary order, so that we also catch | ||
| // protectors on different subtrees. | ||
| // (This unnecessarily checks the tags of `start_idx`s subtree again) |
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.
This comment seems outdated now.
| TreeVisitor { nodes: &mut self.nodes, loc }.traverse_this_parents_children_other( | ||
| *root, | ||
| // Visit all children, skipping none. | ||
| |_| ContinueTraversal::Recurse, | ||
| check_strong_protector, | ||
| )?; |
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.
This part is still duplicated between the two branches... maybe it makes more sense to share the entire visitor invocation, not just the check_strong_protector closure?
This comment has been minimized.
This comment has been minimized.
8c7ac81 to
4097b0a
Compare
|
This PR was rebased onto a different master 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. |
|
@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.
Thanks! Looks good overall but I have plenty of minor comments.
| ) -> InterpResult<'tcx> { | ||
| let idx = self.tag_mapping.insert(new_tag); | ||
| let parent_idx = self.tag_mapping.get(&parent_tag).unwrap(); | ||
|
|
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.
|
@rustbot ready |
| access_kind: AccessKind, | ||
| access_cause: AccessCause, | ||
| access_range: Option<AllocRange>, | ||
| access_cause: AccessCause, //diagnostics | ||
| access_range: Option<AllocRange>, //diagnostics | ||
| relatedness: AccessRelatedness, | ||
| span: Span, | ||
| location_range: Range<u64>, | ||
| span: Span, //diagnostics | ||
| location_range: Range<u64>, //diagnostics | ||
| protected: bool, |
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.
It might make sense to move all the diagnostics arguments into a single struct. Since these just get passed through unchanged all the way from Tree::perform_access.
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.
That seems like a good idea for a future PR. :)
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.
Thanks! However, there are still some comments that need further clarification.
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.
So maybe something like this?
|
This looks great, thanks! Please squash the commits. You can squash manually if there are multiple independent commits you want to preserve, or use @rustbot author |
97353a8 to
e1c480e
Compare
|
@rustbot ready |
Adds proper suport for reborrowing wildcard pointers to tree borrows.