Skip to content

[QUIC]: failing to sometimes create MsQuic configuration #53224

@wfurt

Description

@wfurt

Sometimes when running QUIC tests, the test run fails as (originally reported in #52742)

 Starting:    System.Net.Quic.Functional.Tests (parallel test collections = on, max threads = 2)
      System.Net.Quic.QuicException : ConfigurationOpen failed. Error Code: INVALID_PARAMETER
      Stack Trace:
        /home/furt/github/wfurt-runtime/src/libraries/System.Net.Quic/src/System/Net/Quic/Implementations/MsQuic/Internal/QuicExceptionHelpers.cs(12,0): at System.Net.Quic.Implementations.MsQuic.Internal.QuicExceptionHelpers.ThrowIfFailed(UInt32 status, String message, Exception innerException)
        /home/furt/github/wfurt-runtime/src/libraries/System.Net.Quic/src/System/Net/Quic/Implementations/MsQuic/Interop/SafeMsQuicConfigurationHandle.cs(117,0): at System.Net.Quic.Implementations.MsQuic.Internal.SafeMsQuicConfigurationHandle.Create(QuicOptions options, QUIC_CREDENTIAL_FLAGS flags, X509Certificate certificate, List`1 alpnProtocols)
        /home/furt/github/wfurt-runtime/src/libraries/System.Net.Quic/src/System/Net/Quic/Implementations/MsQuic/Interop/SafeMsQuicConfigurationHandle.cs(34,0): at System.Net.Quic.Implementations.MsQuic.Internal.SafeMsQuicConfigurationHandle.Create(QuicClientConnectionOptions options)
        /home/furt/github/wfurt-runtime/src/libraries/System.Net.Quic/src/System/Net/Quic/Implementations/MsQuic/MsQuicConnection.cs(111,0): at System.Net.Quic.Implementations.MsQuic.MsQuicConnection..ctor(QuicClientConnectionOptions options)
        /home/furt/github/wfurt-runtime/src/libraries/System.Net.Quic/src/System/Net/Quic/Implementations/MsQuic/MsQuicImplementationProvider.cs(19,0): at System.Net.Quic.Implementations.MsQuic.MsQuicImplementationProvider.CreateConnection(QuicClientConnectionOptions options)
        /home/furt/github/wfurt-runtime/src/libraries/System.Net.Quic/src/System/Net/Quic/QuicConnection.cs(44,0): at System.Net.Quic.QuicConnection..ctor(QuicImplementationProvider implementationProvider, QuicClientConnectionOptions options)
        /home/furt/github/wfurt-runtime/src/libraries/System.Net.Quic/src/System/Net/Quic/QuicConnection.cs(37,0): at System.Net.Quic.QuicConnection..ctor(QuicImplementationProvider implementationProvider, EndPoint remoteEndPoint, SslClientAuthenticationOptions sslClientAuthenticationOptions, IPEndPoint localEndPoint)
        /home/furt/github/wfurt-runtime/src/libraries/System.Net.Quic/tests/FunctionalTests/QuicTestBase.cs(53,0): at System.Net.Quic.Tests.QuicTestBase`1.CreateQuicConnection(IPEndPoint endpoint)
        /home/furt/github/wfurt-runtime/src/libraries/System.Net.Quic/tests/FunctionalTests/QuicTestBase.cs(90,0): at System.Net.Quic.Tests.QuicTestBase`1.<>c__DisplayClass16_0.<<RunClientServer>b__1>d.MoveNext()
        --- End of stack trace from previous location ---
        /home/furt/github/wfurt-runtime/src/libraries/Common/tests/System/Threading/Tasks/TaskTimeoutExtensions.cs(55,0): at System.Threading.Tasks.TaskTimeoutExtensions.WhenAllOrAnyFailed(Task[] tasks)
        /home/furt/github/wfurt-runtime/src/libraries/Common/tests/System/Threading/Tasks/TaskTimeoutExtensions.cs(82,0): at System.Threading.Tasks.TaskTimeoutExtensions.WhenAllOrAnyFailed(Task[] tasks)
        /home/furt/github/wfurt-runtime/src/libraries/Common/tests/System/Threading/Tasks/TaskTimeoutExtensions.cs(49,0): at System.Threading.Tasks.TaskTimeoutExtensions.WhenAllOrAnyFailed(Task[] tasks, Int32 millisecondsTimeout)
        /home/furt/github/wfurt-runtime/src/libraries/System.Net.Quic/tests/FunctionalTests/QuicTestBase.cs(78,0): at System.Net.Quic.Tests.QuicTestBase`1.RunClientServer(Func`2 clientFunction, Func`2 serverFunction, Int32 iterations, Int32 millisecondsTimeout)
        /home/furt/github/wfurt-runtime/src/libraries/System.Net.Quic/tests/FunctionalTests/QuicStreamTests.cs(22,0): at System.Net.Quic.Tests.QuicStreamTests`1.BasicTest()
        --- End of stack trace from previous location ---
  Finished:    System.Net.Quic.Functional.Tests

msquic native logs on Linux only show

[1][221e5.2221a][11:29:18.205790][ api] Enter 5 (0x55653138f970).
[1][221e5.2221a][11:29:18.205922][ api] Exit 22

(22 == EINVAL on Linux)

This is coming from this
https://github.com/microsoft/msquic/blob/bde86efb0712f9a1d726c31a9378560e7a9cbdb2/src/core/configuration.c#L62-L69

and length looks like garbage so this is likely another .NET pinning problem.

Few more thoughts on the log:

  • In my case the test run will produce LARGE log file. It is pretty difficult to find the relevant entires. It would be nice if the error cases cases there is clear error log in addition to the entry/exit
  • The enum value will change between platforms. That makes it more difficult IMHO to write guide or know what to look for.
  • on the .NET side I'm wondering if we should show (or log) the handle so it easier to correlate to the native logs.

cc: @nibanks @ThadHouse

The issue is probably pinning of outer buffers with ALPN:

This looks to just take the address of QuicBuffers assuming theyre pinned, but MsQuicAlpnHelper.Prepare doesn't pin the outer buffers, just the inner buffers.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions