-
Notifications
You must be signed in to change notification settings - Fork 13.7k
interpret/allocation: get_range on ProvenanceMap #145540
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: master
Are you sure you want to change the base?
Conversation
rustbot has assigned @matthewjasper. Use |
cx: &impl HasDataLayout, | ||
range: AllocRange, | ||
) -> impl Iterator<Item = (Size, Prov)> { | ||
let ptr_provs = self.range_ptrs_get(range, cx).to_owned(); |
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.
Why are you calling to_owned
here?
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.
Fair, .iter().copied()
would have been better I think but either way it's unnecessary if this doesn't return the offset per your other suggestion
&self, | ||
cx: &impl HasDataLayout, | ||
range: AllocRange, | ||
) -> impl Iterator<Item = (Size, Prov)> { |
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.
There's no point in including the offset since one cannot even know whether that's a 1-byte provenance or a whole-ptr provenance. So either drop the Size
, or add an Option<u8>
carrying that information.
@@ -148,6 +148,17 @@ impl<Prov: Provenance> ProvenanceMap<Prov> { | |||
true | |||
} | |||
|
|||
/// Gets the provenances of all bytes (including from pointers) in a range. | |||
pub fn get_range( |
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 move this up so it is next to get_byte
.
cx: &impl HasDataLayout, | ||
range: AllocRange, | ||
) -> impl Iterator<Item = Prov> { | ||
let ptr_provs = self.range_ptrs_get(range, cx).iter().map(|(_, p)| *p); |
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 is the wrong range. You have to use adjusted_range_ptrs
.
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.
Doesn't adjusted_range_ptrs
only give us the offsets and not provenances? range_ptrs_get
uses that internally anyways
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.
Ah, d'oh, right...
I shouldn't review when I am too tired.^^
☔ The latest upstream changes (presumably #145647) made this pull request unmergeable. Please resolve the merge conflicts. |
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. |
Please squash then we can land this. |
Great! Since you think it's fine, r? RalfJung |
@bors r+ rollup |
interpret/allocation: get_range on ProvenanceMap Helper method to grab all provenances in a given address range for an allocation, making some logic in Miri nicer.
Rollup of 7 pull requests Successful merges: - #144452 (std/sys/fd: Relax `READ_LIMIT` on Darwin) - #145307 (Fix `LazyLock` poison panic message) - #145515 (Optimize `char::encode_utf8`) - #145540 (interpret/allocation: get_range on ProvenanceMap) - #145774 (Remove default opts from config) - #145780 (Do not warn about missing change ID in tarball builds) - #145781 (Remove profile section from Clippy) r? `@ghost` `@rustbot` modify labels: rollup
Helper method to grab all provenances in a given address range for an allocation, making some logic in Miri nicer.