Skip to content

Conversation

@VSadov
Copy link
Member

@VSadov VSadov commented Nov 26, 2025

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.

@dotnet-policy-service
Copy link
Contributor

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

@VSadov VSadov changed the title [RUntimeAsync] Skip over nonuser continuations when searching for awaiter configuration [RuntimeAsync] Skip over nonuser continuations when searching for awaiter configuration Nov 26, 2025
@VSadov VSadov marked this pull request as ready for review November 27, 2025 00:31
Copilot AI review requested due to automatic review settings November 27, 2025 00:31
Copilot finished reviewing on behalf of VSadov November 27, 2025 00:34
Copy link
Contributor

Copilot AI left a 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

@VSadov VSadov enabled auto-merge (squash) November 28, 2025 16:36
@VSadov
Copy link
Member Author

VSadov commented Nov 28, 2025

Thanks!

@VSadov VSadov merged commit 96acc3c into dotnet:main Nov 28, 2025
102 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ensure IL instantiating/unboxing stubs are transparent in await behavior

2 participants