Skip to content

interpret: fix after_local_read handling - #161646

Merged
rust-bors[bot] merged 4 commits into
rust-lang:mainfrom
RalfJung:after_local_read
Aug 25, 2026
Merged

interpret: fix after_local_read handling#161646
rust-bors[bot] merged 4 commits into
rust-lang:mainfrom
RalfJung:after_local_read

Conversation

@RalfJung

@RalfJung RalfJung commented Aug 24, 2026

Copy link
Copy Markdown
Member

after_local_read handling was wrong in two ways:

  • Contrary to what was documented, we invoked it for all reads of locals, not just reads of locals that have their values stored as immediates (without memory).
  • Miri effectively ignored the frame we are passing to it. And indeed we never want this called on anything but the current frame, also for consistency with the corresponding write hook.

So let's restrict local_to_op to the current frame.
Debuggers/visualizers should be able to use the existing method on LocalState that Miri also needs for its provenance visitor. Its name was not sufficiently scary for skipping access hooks, so I also overhauled how we name these "fake"/"ghost" access related APIs.

@rustbot

rustbot commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred to the CTFE machinery

cc @oli-obk, @lcnr

miri is developed in its own repository. If the Miri part of this change can be broken out, consider making this change to rust-lang/miri instead. However, if Miri needs adjusting for rustc changes, just ignore this message.

cc @rust-lang/miri

Some changes occurred to the CTFE / Miri interpreter

cc @rust-lang/miri

@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 24, 2026
@rustbot

rustbot commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator

r? @mu001999

rustbot has assigned @mu001999.
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

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler, mir
  • compiler, mir expanded to 75 candidates
  • Random selection from 19 candidates

Comment thread compiler/rustc_const_eval/src/interpret/operand.rs
@mu001999

Copy link
Copy Markdown
Member

@rustbot reroll

@rustbot rustbot assigned wesleywiser and unassigned mu001999 Aug 24, 2026
@rust-log-analyzer

This comment has been minimized.

@rustbot

rustbot commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator

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.

@RalfJung

Copy link
Copy Markdown
Member Author

Since Oli is on vacation
r? @saethlin

This turned now into a bit of a refactor of how we handle "not-real accesses".

@rustbot rustbot assigned saethlin and unassigned wesleywiser Aug 24, 2026
@saethlin

Copy link
Copy Markdown
Member

@bors r+

@rust-bors

rust-bors Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 531e812 has been approved by saethlin

It is now in the queue for this repository.

@rust-bors rust-bors Bot 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 25, 2026
Zalathar added a commit to Zalathar/rust that referenced this pull request Aug 25, 2026
interpret: fix after_local_read handling

`after_local_read` handling was wrong in two ways:
- Contrary to what was documented, we invoked it for all reads of locals, not just reads of locals that have their values stored as immediates (without memory).
- Miri effectively ignored the `frame` we are passing to it. And indeed we never want this called on anything but the current frame, also for consistency with the corresponding write hook.

So let's restrict `local_to_op` to the current frame.
Debuggers/visualizers should be able to use the existing method on `LocalState` that Miri also needs for its provenance visitor. Its name was not sufficiently scary for skipping access hooks, so I also overhauled how we name these "fake"/"ghost" access related APIs.
rust-bors Bot pushed a commit that referenced this pull request Aug 25, 2026
Rollup of 9 pull requests

Successful merges:

 - #160533 (dirfd dir operations (3/4))
 - #161294 (add crashtests [6/N])
 - #160392 (library: motor: bump moto-rt ABI ver to 17)
 - #161646 (interpret: fix after_local_read handling)
 - #160819 (Rework `div_ceil` for nonzero integers)
 - #161591 (run `classify-runtime-const` test for `f128`)
 - #161680 (renovate: add lockfile update warning)
 - #161702 (Use `drop_guard` in some places in {core,alloc,std})
 - #161709 (Stop rustfmt deleting attributes in fn params)
rust-bors Bot pushed a commit that referenced this pull request Aug 25, 2026
…uwer

Rollup of 10 pull requests

Successful merges:

 - #160533 (dirfd dir operations (3/4))
 - #161294 (add crashtests [6/N])
 - #160392 (library: motor: bump moto-rt ABI ver to 17)
 - #161646 (interpret: fix after_local_read handling)
 - #161682 (Update books)
 - #160819 (Rework `div_ceil` for nonzero integers)
 - #161204 (core: Make funnel shifts panic only if overflow checks are enabled)
 - #161591 (run `classify-runtime-const` test for `f128`)
 - #161680 (renovate: add lockfile update warning)
 - #161709 (Stop rustfmt deleting attributes in fn params)
@rust-bors
rust-bors Bot merged commit 1a7654d into rust-lang:main Aug 25, 2026
13 checks passed
@rustbot rustbot added this to the 1.100.0 milestone Aug 25, 2026
rust-bors Bot pushed a commit that referenced this pull request Aug 25, 2026
Rollup merge of #161646 - RalfJung:after_local_read, r=saethlin

interpret: fix after_local_read handling

`after_local_read` handling was wrong in two ways:
- Contrary to what was documented, we invoked it for all reads of locals, not just reads of locals that have their values stored as immediates (without memory).
- Miri effectively ignored the `frame` we are passing to it. And indeed we never want this called on anything but the current frame, also for consistency with the corresponding write hook.

So let's restrict `local_to_op` to the current frame.
Debuggers/visualizers should be able to use the existing method on `LocalState` that Miri also needs for its provenance visitor. Its name was not sufficiently scary for skipping access hooks, so I also overhauled how we name these "fake"/"ghost" access related APIs.
@RalfJung
RalfJung deleted the after_local_read branch August 25, 2026 12:13
pull Bot pushed a commit to LeeeeeeM/miri that referenced this pull request Aug 26, 2026
…uwer

Rollup of 10 pull requests

Successful merges:

 - rust-lang/rust#160533 (dirfd dir operations (3/4))
 - rust-lang/rust#161294 (add crashtests [6/N])
 - rust-lang/rust#160392 (library: motor: bump moto-rt ABI ver to 17)
 - rust-lang/rust#161646 (interpret: fix after_local_read handling)
 - rust-lang/rust#161682 (Update books)
 - rust-lang/rust#160819 (Rework `div_ceil` for nonzero integers)
 - rust-lang/rust#161204 (core: Make funnel shifts panic only if overflow checks are enabled)
 - rust-lang/rust#161591 (run `classify-runtime-const` test for `f128`)
 - rust-lang/rust#161680 (renovate: add lockfile update warning)
 - rust-lang/rust#161709 (Stop rustfmt deleting attributes in fn params)
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.

8 participants