-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[RuntimeAsync] Skip over nonuser continuations when searching for awaiter configuration #121976
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
Conversation
|
Tagging subscribers to this area: @mangod9 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
src/coreclr/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncHelpers.CoreCLR.cs
Outdated
Show resolved
Hide resolved
This reverts commit fe01440.
|
Thanks! |
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.