runtime: ClientAndServer_OneOrBothUseDefault_Ok failed in CI with ObjectDisposedException

Tests:

  • System.Net.Security.Tests.ApmSslStreamSystemDefaultTest.ClientAndServer_OneOrBothUseDefault_Ok
  • System.Net.Security.Tests.SyncSslStreamSystemDefaultTest.ClientAndServer_OneOrBothUseDefault_Ok

Hits:

  • dotnet/corefx#41936 - System.Net.Security.Tests.AsyncSslStreamSystemDefaultTest.ClientAndServer_OneOrBothUseDefault_Ok(clientProtocols: Tls | Tls11 | Tls12, serverProtocols: null) failing in CI with ObjectDisposedException

https://dnceng.visualstudio.com/public/_build/results?buildId=331181&view=ms.vss-test-web.build-test-results-tab&runId=9703666&resultId=167383&paneView=debug

Configuration: netcoreapp-Windows_NT-Release-x64-Windows.81.Amd64.Open

System.Net.Security.Tests.ApmSslStreamSystemDefaultTest.ClientAndServer_OneOrBothUseDefault_Ok(clientProtocols: Tls11, serverProtocols: Ssl2 | Default | Tls11 | Tls12)

System.ObjectDisposedException : Safe handle has been closed.\r\nObject name: 'SafeHandle'.

at System.Runtime.InteropServices.SafeHandle.DangerousAddRef(Boolean& success) in /_/src/System.Private.CoreLib/shared/System/Runtime/InteropServices/SafeHandle.cs:line 158
   at System.Net.Security.SafeCredentialReference..ctor(SafeFreeCredentials target) in /_/src/Common/src/Interop/Windows/SspiCli/SecuritySafeHandles.cs:line 354
   at System.Net.Security.SafeCredentialReference.CreateReference(SafeFreeCredentials target) in /_/src/Common/src/Interop/Windows/SspiCli/SecuritySafeHandles.cs:line 340
   at System.Net.Security.SslSessionsCache.CacheCredential(SafeFreeCredentials creds, Byte[] thumbPrint, SslProtocols sslProtocols, Boolean isServer, EncryptionPolicy encryptionPolicy) in /_/src/System.Net.Security/src/System/Net/Security/SslSessionsCache.cs:line 201
   at System.Net.Security.SecureChannel.GenerateToken(Byte[] input, Int32 offset, Int32 count, Byte[]& output) in /_/src/System.Net.Security/src/System/Net/Security/SecureChannel.cs:line 846
   at System.Net.Security.SecureChannel.NextMessage(Byte[] incoming, Int32 offset, Int32 count) in /_/src/System.Net.Security/src/System/Net/Security/SecureChannel.cs:line 738
   at System.Net.Security.SslStream.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest) in /_/src/System.Net.Security/src/System/Net/Security/SslStream.Implementation.cs:line 446
   at System.Net.Security.SslStream.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest) in /_/src/System.Net.Security/src/System/Net/Security/SslStream.Implementation.cs:line 662
   at System.Net.Security.SslStream.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest) in /_/src/System.Net.Security/src/System/Net/Security/SslStream.Implementation.cs:line 617
   at System.Net.Security.SslStream.PartialFrameCallback(AsyncProtocolRequest asyncRequest) in /_/src/System.Net.Security/src/System/Net/Security/SslStream.Implementation.cs:line 796
--- End of stack trace from previous location where exception was thrown ---
   at System.Net.Security.SslStream.<ThrowIfExceptional>g__ThrowExceptional|141_0(ExceptionDispatchInfo e) in /_/src/System.Net.Security/src/System/Net/Security/SslStream.cs:line 844
   at System.Net.Security.SslStream.ThrowIfExceptional() in /_/src/System.Net.Security/src/System/Net/Security/SslStream.cs:line 845
   at System.Net.Security.SslStream.InternalEndProcessAuthentication(LazyAsyncResult lazyResult) in /_/src/System.Net.Security/src/System/Net/Security/SslStream.Implementation.cs:line 439
   at System.Net.Security.SslStream.EndProcessAuthentication(IAsyncResult result) in /_/src/System.Net.Security/src/System/Net/Security/SslStream.Implementation.cs:line 410
   at System.Net.Security.SslStream.EndAuthenticateAsClient(IAsyncResult asyncResult) in /_/src/System.Net.Security/src/System/Net/Security/SslStream.cs:line 241
   at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization) in /_/src/System.Private.CoreLib/shared/System/Threading/Tasks/FutureFactory.cs:line 514
--- End of stack trace from previous location where exception was thrown ---
   at System.Threading.Tasks.TaskTimeoutExtensions.WhenAllOrAnyFailed(Task[] tasks) in /_/src/Common/tests/System/Threading/Tasks/TaskTimeoutExtensions.cs:line 83
   at System.Threading.Tasks.TaskTimeoutExtensions.WhenAllOrAnyFailed(Task[] tasks) in /_/src/Common/tests/System/Threading/Tasks/TaskTimeoutExtensions.cs:line 111
   at System.Threading.Tasks.TaskTimeoutExtensions.WhenAllOrAnyFailed(Task[] tasks, Int32 millisecondsTimeout) in /_/src/Common/tests/System/Threading/Tasks/TaskTimeoutExtensions.cs:line 71
   at System.Net.Security.Tests.SslStreamSystemDefaultTest.ClientAndServer_OneOrBothUseDefault_Ok(Nullable`1 clientProtocols, Nullable`1 serverProtocols) in /_/src/System.Net.Security/tests/FunctionalTests/SslStreamSystemDefaultsTest.cs:line 63
--- End of stack trace from previous location where exception was thrown ---

cc @davidsh, @wfurt, @scalablecory, @eiriktsarpalis, @karelz

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 20 (10 by maintainers)

Most upvoted comments

I was able to reproduce this locally on my W11 VM (~ 250 runs) I will take a look.

    System.Net.Security.Tests.ApmSslStreamSystemDefaultTest.ClientAndServer_OneOrBothUseDefault_Ok(clientProtocols: Tls12, serverProtocols: null) [FAIL]
      System.ObjectDisposedException : Safe handle has been closed.
      Object name: 'SafeHandle'.
      Stack Trace:
        C:\Users\test\github\wfurt-runtime2\src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\SafeHandle.cs(150,0): at System.Runtime.InteropServices.SafeHandle.DangerousAddRef(Boolean& success)
        C:\Users\test\github\wfurt-runtime2\src\libraries\Common\src\System\Net\Security\SafeCredentialReference.cs(33,0): at System.Net.Security.SafeCredentialReference..ctor(SafeFreeCredentials target)
        C:\Users\test\github\wfurt-runtime2\src\libraries\Common\src\System\Net\Security\SafeCredentialReference.cs(25,0): at System.Net.Security.SafeCredentialReference.CreateReference(SafeFreeCredentials target)
        C:\Users\test\github\wfurt-runtime2\src\libraries\System.Net.Security\src\System\Net\Security\SslSessionsCache.cs(225,0): at System.Net.Security.SslSessionsCache.<CacheCredential>g__ShrinkCredentialCache|5_0()
        C:\Users\test\github\wfurt-runtime2\src\libraries\System.Net.Security\src\System\Net\Security\SslSessionsCache.cs(182,0): at System.Net.Security.SslSessionsCache.CacheCredential(SafeFreeCredentials creds, Byte[] thumbPrint, SslProtocols sslProtocols, Boolean isServer, EncryptionPolicy encryptionPolicy)
        C:\Users\test\github\wfurt-runtime2\src\libraries\System.Net.Security\src\System\Net\Security\SecureChannel.cs(823,0): at System.Net.Security.SecureChannel.GenerateToken(ReadOnlySpan`1 inputBuffer, Byte[]& output)
        C:\Users\test\github\wfurt-runtime2\src\libraries\System.Net.Security\src\System\Net\Security\SecureChannel.cs(731,0): at System.Net.Security.SecureChannel.NextMessage(ReadOnlySpan`1 incomingBuffer)
        C:\Users\test\github\wfurt-runtime2\src\libraries\System.Net.Security\src\System\Net\Security\SslStream.Implementation.cs(594,0): at System.Net.Security.SslStream.ProcessBlob(Int32 frameSize)
        C:\Users\test\github\wfurt-runtime2\src\libraries\System.Net.Security\src\System\Net\Security\SslStream.Implementation.cs(556,0): at System.Net.Security.SslStream.ReceiveBlobAsync[TIOAdapter](TIOAdapter adapter)
        C:\Users\test\github\wfurt-runtime2\src\libraries\System.Net.Security\src\System\Net\Security\SslStream.Implementation.cs(381,0): at System.Net.Security.SslStream.ForceAuthenticationAsync[TIOAdapter](TIOAdapter adapter, Boolean receiveFirst, Byte[] reAuthenticationData, Boolean isApm)
        C:\Users\test\github\wfurt-runtime2\src\libraries\Common\src\System\Threading\Tasks\TaskToApm.cs(41,0): at System.Threading.Tasks.TaskToApm.End(IAsyncResult asyncResult)
        C:\Users\test\github\wfurt-runtime2\src\libraries\System.Net.Security\src\System\Net\Security\SslStream.cs(211,0): at System.Net.Security.SslStream.EndAuthenticateAsClient(IAsyncResult asyncResult)
        C:\Users\test\github\wfurt-runtime2\src\libraries\System.Private.CoreLib\src\System\Threading\Tasks\FutureFactory.cs(511,0): at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
        --- End of stack trace from previous location ---
        C:\Users\test\github\wfurt-runtime2\src\libraries\Common\tests\System\Threading\Tasks\TaskTimeoutExtensions.cs(64,0): at System.Threading.Tasks.TaskTimeoutExtensions.WhenAllOrAnyFailed(Task[] tasks)
        C:\Users\test\github\wfurt-runtime2\src\libraries\Common\tests\System\Threading\Tasks\TaskTimeoutExtensions.cs(91,0): at System.Threading.Tasks.TaskTimeoutExtensions.WhenAllOrAnyFailed(Task[] tasks)
        C:\Users\test\github\wfurt-runtime2\src\libraries\Common\tests\System\Threading\Tasks\TaskTimeoutExtensions.cs(55,0): at System.Threading.Tasks.TaskTimeoutExtensions.WhenAllOrAnyFailed(Task[] tasks, Int32 millisecondsTimeout)
        C:\Users\test\github\wfurt-runtime2\src\libraries\System.Net.Security\tests\FunctionalTests\SslStreamSystemDefaultsTest.cs(86,0): at System.Net.Security.Tests.SslStreamSystemDefaultTest.ClientAndServer_OneOrBothUseDefault_Ok(Nullable`1 clientProtocols, Nullable`1 serverProtocols)
        --- End of stack trace from previous location ---
  Finished:    System.Net.Security.Tests
=== TEST EXECUTION SUMMARY ===
   System.Net.Security.Tests  Total: 5002, Errors: 0, Failed: 1, Skipped: 21, Time: 17.633s

C:\Users\test\github\wfurt-runtime2\artifacts\bin\System.Net.Security.Tests\net6.0-windows-Debug>set RESULT=1

C:\Users\test\github\wfurt-runtime2\artifacts\bin\System.Net.Security.Tests\net6.0-windows-Debug>echo echo netsh.exe trace stop
echo netsh.exe trace stop

C