Skip to content

JIT: Do not reuse local addresses across suspension points in async methods - #134511

Merged
jakobbotsch merged 1 commit into
dotnet:mainfrom
jakobbotsch:fix-133588
Sep 24, 2026
Merged

jakobbotsch merged 1 commit into
dotnet:mainfrom
jakobbotsch:fix-133588

Conversation

@jakobbotsch

Copy link
Copy Markdown
Member

Locals move to a new frame when an async method resumes, but this was not modelled by VN. Add a "frame version" argument to VNF_PtrToLoc that is unique per GT_LCL_ADDR in async methods. Number loads of address-exposed locals with a new VNF_ByrefExposedLocalLoad that ignores the frame version to avoid regressions.

Fix #133588

…ethods

Locals move to a new frame when an async method resumes, but `TYP_I_IMPL`-typed
local addresses were not covered by the byref-only CSE kills at suspension
points and could be reused after resumption.

Add a "frame version" argument to `VNF_PtrToLoc` that is unique per
`GT_LCL_ADDR` in async methods. Number loads of address-exposed locals with a
new `VNF_ByrefExposedLocalLoad` that ignores the frame version.

Fix dotnet#133588

Co-authored-by: Copilot <[email protected]>
Copilot-Session: ef38ea02-2a4e-45b5-8127-86b751617a68
Copilot AI lite review requested due to automatic review settings September 23, 2026 12:15
@github-actions github-actions Bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Sep 23, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 5 pipeline(s).
11 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

@jakobbotsch jakobbotsch changed the title JIT: Do not reuse local addresses across suspension points in async m… JIT: Do not reuse local addresses across suspension points in async methods Sep 23, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Critical async value-numbering paths can still reuse stale local addresses across suspension points.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 2 High severity

Open (2)
What changed in this PR

This pull request prevents JIT reuse of local addresses across async suspension points and adds regression coverage for issue #133588.

Changes:

  • Adds frame-versioned VNF_PtrToLoc handling.
  • Adds VNF_ByrefExposedLocalLoad.
  • Adds and registers an async regression test.
File Description
src/​tests/​async/​regression/​133588.csproj Registers the regression test project.
src/​tests/​async/​regression/​133588.cs Reproduces stale-address behavior.
src/​coreclr/​jit/​valuenumfuncs.h Defines updated value-numbering functions.
src/​coreclr/​jit/​valuenum.cpp Implements frame-aware address numbering and local-load handling.
src/​coreclr/​jit/​compiler.h Declares the new helper.

Comment thread src/coreclr/jit/valuenum.cpp Resolved
Comment thread src/coreclr/jit/valuenum.cpp Resolved
@jakobbotsch

Copy link
Copy Markdown
Member Author

cc @dotnet/jit-contrib PTAL @EgorBo

One diff

@jakobbotsch
jakobbotsch requested a review from EgorBo September 23, 2026 15:11
Comment thread src/coreclr/jit/valuenumfuncs.h Resolved

@EgorBo EgorBo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with a question

@jakobbotsch
jakobbotsch merged commit 984e4d2 into dotnet:main Sep 24, 2026
146 of 147 checks passed
@jakobbotsch
jakobbotsch deleted the fix-133588 branch September 24, 2026 09:35
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Sep 25, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 25, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JIT: (bug) Native-int-typed stack address is CSE'd across an await and reused after resumption

3 participants