[Runtime Async] do not hold to continuation state when completing reusable valuetask sources#124491
Merged
VSadov merged 1 commit intodotnet:mainfrom Feb 17, 2026
Merged
[Runtime Async] do not hold to continuation state when completing reusable valuetask sources#124491VSadov merged 1 commit intodotnet:mainfrom
VSadov merged 1 commit intodotnet:mainfrom
Conversation
Contributor
|
Tagging subscribers to this area: @agocke, @VSadov |
This was referenced Feb 17, 2026
jakobbotsch
approved these changes
Feb 17, 2026
Member
jakobbotsch
left a comment
There was a problem hiding this comment.
LGTM, but not my usual area of expertise.
Member
Author
|
/ba-g mono interpreter failure is #124525 |
Member
Author
It is a fairly trivial change. If we do not keep the continuation delegate after calling it, there is no need to keep the arguments for the call. 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 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.
Not exactly in the Runtime Async implementation, but the issue was found while testing Runtime Async in Libraries.
There is a scenario where ValueTaskSource upon completion invokes stashed
{_continuation, _continuationState}. It is a one-shot invocation. Neither of{_continuation, _continuationState}are needed after that. However, while we naturally unroot_continuationby replacing it with a sentinel, the_continuationStatewill stay rooted until the VTS is reused.As a result, if continuation expects that some state (like
Http3ReadStream) gets finalized, it may not see that no matter how long it waits/checks/retries.The retention was observable in intermittent failures in:
(scenario may depend on mutual timings between Server and Client and whether sync/async paths are taken)
The whole purpose of the test is to see that if client drops the connection on the floor, it becomes unreachable reasonably soon and Finalization logic closes the connection.
What we see instead is the test waits for a long time and eventually times out.
A similar code pattern was observed in
Threading/Channels/AsyncOperation.Although I did not see any failures due to that, I applied the same fix of zeroing out the
_continuationStatebefore invoking the continuation.Same applies to the
_capturedContext. No need to hold to that for longer than needed.