Skip to content

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nia-e
Copy link
Contributor

@nia-e nia-e commented Aug 17, 2025

Helper method to grab all provenances in a given address range for an allocation, making some logic in Miri nicer.

@rustbot
Copy link
Collaborator

rustbot commented Aug 17, 2025

r? @matthewjasper

rustbot has assigned @matthewjasper.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 17, 2025
@rustbot
Copy link
Collaborator

rustbot commented Aug 17, 2025

The Miri subtree was changed

cc @rust-lang/miri

Some changes occurred to the CTFE / Miri interpreter

cc @rust-lang/miri, @RalfJung, @oli-obk, @lcnr

cx: &impl HasDataLayout,
range: AllocRange,
) -> impl Iterator<Item = (Size, Prov)> {
let ptr_provs = self.range_ptrs_get(range, cx).to_owned();
Copy link
Member

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?

Copy link
Contributor Author

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)> {
Copy link
Member

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(
Copy link
Member

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);
Copy link
Member

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.

Copy link
Contributor Author

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

Copy link
Member

@RalfJung RalfJung Aug 21, 2025

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.^^

@bors
Copy link
Collaborator

bors commented Aug 21, 2025

☔ The latest upstream changes (presumably #145647) made this pull request unmergeable. Please resolve the merge conflicts.

@rustbot
Copy link
Collaborator

rustbot commented Aug 21, 2025

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.

@RalfJung
Copy link
Member

Please squash then we can land this.

@nia-e
Copy link
Contributor Author

nia-e commented Aug 22, 2025

Great! Since you think it's fine,

r? RalfJung

@rustbot rustbot assigned RalfJung and unassigned matthewjasper Aug 22, 2025
@RalfJung
Copy link
Member

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Aug 23, 2025

📌 Commit 7046ce8 has been approved by RalfJung

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 23, 2025
samueltardieu added a commit to samueltardieu/rust that referenced this pull request Aug 23, 2025
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.
bors added a commit that referenced this pull request Aug 23, 2025
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants