You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[RuntimeAsync] Runtime Async may not honor ExecutionContext.SuppressFlow(). #122052
Flowing execution context when it is suppressed is observable. One purpose for suppressing could be hiding secrets, although most commonly the flow is suppressed for performance reasons.
Not reacting to suppression may result in failures like:
System.Net.Sockets.Tests.ExecutionContextFlowTest.SocketAsyncEventArgs_ExecutionContextFlowsAcrossSendAsyncOperation(suppressContext: True, sendMode: 2) [FAIL]
Assert.Equal() Failure: Values differ
Expected: 0
Actual: 42
Stack Trace:
/_/src/libraries/System.Net.Sockets/tests/FunctionalTests/ExecutionContextFlowTest.cs(345,0): at System.Net.Sockets.Tests.ExecutionContextFlowTest.SocketAsyncEventArgs_ExecutionContextFlowsAcrossSendAsyncOperation(Boolean suppressContext, Int32 sendMode)
/_/src/coreclr/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncHelpers.CoreCLR.cs(478,0): at System.Runtime.CompilerServices.AsyncHelpers.RuntimeAsyncTaskCore.DispatchContinuations[T,TOps](T task)
--- End of stack trace from previous location ---
--- End of stack trace from previous location ---
Finished: System.Net.Sockets.Tests
== Edit: RestoreContextsOnSuspension may be used for synchronous restore (i.e. before calling into notifier). CaptureExecutionContext could be a more appropriate place.
This is not fixed if DOTNET_JitOptimizeAwait is set to 0.
The unoptimized path uses the actual awaiter, thus we typically do not have compat issues there.
When there is no Task/awaiter - that is when we get into all kind of trouble and need to simulate what awaiter would do.
It is possible though that somehow we still have an issue or something regressed.
How did it reproduce? Just via running some existing tests with set DOTNET_JitOptimizeAwait=0 ?
Activity
VSadov commentedon Nov 29, 2025
I think this can be fixed by simply checking for
IsFlowSuppressedinRestoreContextsOnSuspensionand not capturing exec context, but need to be sure.Possible Fix: 2982687
== Edit:
RestoreContextsOnSuspensionmay be used for synchronous restore (i.e. before calling into notifier).CaptureExecutionContextcould be a more appropriate place.[RuntimeAsync] Respect IsFlowSuppressed when capturing execution cont…
davidwrighton commentedon Jan 6, 2026
This is not fixed if DOTNET_JitOptimizeAwait is set to 0.
VSadov commentedon Jan 7, 2026
The unoptimized path uses the actual awaiter, thus we typically do not have compat issues there.
When there is no Task/awaiter - that is when we get into all kind of trouble and need to simulate what awaiter would do.
It is possible though that somehow we still have an issue or something regressed.
How did it reproduce? Just via running some existing tests with
set DOTNET_JitOptimizeAwait=0?VSadov commentedon Jul 3, 2026
we should run tests with
set DOTNET_JitOptimizeAwait=0and see what happens