[RuntimeAsync] Skip over nonuser continuations when searching for awaiter configuration#121976
Merged
VSadov merged 8 commits intodotnet:mainfrom Nov 28, 2025
Merged
[RuntimeAsync] Skip over nonuser continuations when searching for awaiter configuration#121976VSadov merged 8 commits intodotnet:mainfrom
VSadov merged 8 commits intodotnet:mainfrom
Conversation
Contributor
|
Tagging subscribers to this area: @mangod9 |
jakobbotsch
reviewed
Nov 27, 2025
jakobbotsch
reviewed
Nov 27, 2025
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes issue #121971 by enabling the runtime async feature to correctly handle transparent/infrastructure code (such as unboxing stubs) that may exist between user code and ValueTask-returning methods. The fix ensures that when determining the awaiter configuration, the runtime walks through the continuation chain to skip over non-user continuations and find the actual user continuation that holds the configuration flags.
Key Changes:
- Modified continuation chain walking logic in AsyncHelpers.CoreCLR.cs to skip transparent continuations when determining awaiter configuration
- Enabled RuntimeAsync feature by default in CoreCLR configuration
- Added a comprehensive test case that validates the fix by using a generic interface method with many parameters to trigger unboxing stub creation
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/coreclr/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncHelpers.CoreCLR.cs | Implements the core fix by adding a while loop to skip over transparent continuations and access the correct user continuation for configuration flags |
| src/coreclr/inc/clrconfigvalues.h | Changes the default value of RuntimeAsync from 0 to 1, enabling the feature by default |
| src/tests/async/Directory.Build.targets | Removes the PropertyGroup that was disabling async tests for non-NativeAOT builds, enabling these tests to run on CoreCLR |
| src/tests/async/valuetask-source/valuetask-source-stub.cs | Adds new test case that reproduces the scenario with transparent continuations (unboxing stubs) between user code and ValueTask source |
| src/tests/async/valuetask-source/valuetask-source-stub.csproj | Test project configuration with required optimizations and JIT settings to ensure the test scenario is properly triggered |
src/coreclr/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncHelpers.CoreCLR.cs
Outdated
Show resolved
Hide resolved
src/coreclr/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncHelpers.CoreCLR.cs
Outdated
Show resolved
Hide resolved
src/coreclr/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncHelpers.CoreCLR.cs
Outdated
Show resolved
Hide resolved
src/coreclr/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncHelpers.CoreCLR.cs
Outdated
Show resolved
Hide resolved
src/coreclr/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncHelpers.CoreCLR.cs
Outdated
Show resolved
Hide resolved
jakobbotsch
reviewed
Nov 27, 2025
src/coreclr/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncHelpers.CoreCLR.cs
Outdated
Show resolved
Hide resolved
jakobbotsch
approved these changes
Nov 28, 2025
This reverts commit fe01440.
Member
Author
|
Thanks! |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Fixes: #121971
Sometimes we have transparent/infrastructure code between user code and a ValueTask-returning method that wraps IValueTaskSource. An example is an unboxing stub.
This is the scenario where we need to figure the configuration of the await operation by looking at continuation that corresponds to the user code (only those are configured).
In a case if we see transparent continuations, we should just continue walking continuation chain.