Move the return var out of liveLocalsIntervals#127931
Open
BrzVlad wants to merge 1 commit intodotnet:mainfrom
Open
Move the return var out of liveLocalsIntervals#127931BrzVlad wants to merge 1 commit intodotnet:mainfrom
BrzVlad wants to merge 1 commit intodotnet:mainfrom
Conversation
Member
Author
|
/azp run runtime-libraries-interpreter |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Contributor
|
Tagging subscribers to this area: @JulieLeeMSFT, @BrzVlad, @janvorli, @kg |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes interpreter async continuation state capture so the awaited call’s return value is no longer treated as a normal “live local” to copy into the continuation object (which previously could copy uninitialized stack data and lead to GC consistency crashes in interpreter mode). Instead, it tracks return-value metadata separately and restores the return value explicitly during the resume path.
Changes:
- Exclude the call return-value var from
liveVarswhen emitting async suspend data, and record dedicated return-value metadata (size+ stack offset) inInterpAsyncSuspendData. - Adjust interpreter continuation suspend/resume copy logic so live locals are copied after the continuation’s result storage region, and explicitly copy the return value from
GetResultStorage()back to the interpreter stack on resume. - Add fixup logic so the stored “return value var” is patched from var index to final stack offset during interval-map finalization.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/coreclr/vm/interpexec.cpp | Shifts live-local copy region past result storage; adds explicit return-value restore on resume. |
| src/coreclr/interpreter/inc/interpretershared.h | Extends InterpAsyncSuspendData with return-value continuation size and stack offset metadata. |
| src/coreclr/interpreter/compiler.cpp | Stops treating return-value var as a live var; computes/stores return-value metadata and patches it during interval-map update. |
Comment on lines
+6024
to
+6032
| } | ||
| else | ||
| { | ||
| suspendData->returnValueContinuationDataSize = 0; | ||
| } | ||
|
|
||
| // Patched up in UpdateLocalIntervalMaps to hold the actual offset of the var | ||
| suspendData->returnValueVarStackOffset = returnValueVar; | ||
|
|
When generating an async call, in EmitSuspend, we obtain the set of vars that are alive at this point in time and we store this information inside the suspenData. If they async call needs to suspend it will store these vars into the ContinuationObject, with their values being restored when we resume the continuation. Previous code would store the result value as well into the ContinuationObject. The problem is that this would lead to storing uninitialized data into the object, which can result in random GC crashes. This commit removes the result var from the set of live vars, stores associated information specifically for the return var inside the suspend data and we make use of this information to write the result only on the suspend resume path.
94adc6a to
0dc387b
Compare
This was referenced May 8, 2026
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When generating an async call, in EmitSuspend, we obtain the set of vars that are alive at this point in time and we store this information inside the suspenData. If they async call needs to suspend it will store these vars into the ContinuationObject, with their values being restored when we resume the continuation.
Previous code would store the result value as well into the ContinuationObject. The problem is that this would lead to storing uninitialized data into the object, which can result in random GC crashes. This commit removes the result var from the set of live vars, stores associated information specifically for the return var inside the suspend data and we make use of this information to write the result only on the suspend resume path.
Fixes #127855