Skip to content

[RuntimeAsync] Runtime Async may not honor ExecutionContext.SuppressFlow(). #122052

@VSadov

Description

@VSadov

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

Metadata

Metadata

Assignees

Type

No type

Projects

Status

No status

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions