Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ClientAndServer_OneOrBothUseDefault_Ok failed in CI with ObjectDisposedException #30724

Closed
ViktorHofer opened this issue Aug 30, 2019 · 20 comments · Fixed by #58594
Closed

ClientAndServer_OneOrBothUseDefault_Ok failed in CI with ObjectDisposedException #30724

ViktorHofer opened this issue Aug 30, 2019 · 20 comments · Fixed by #58594
Assignees
Labels
Milestone

Comments

@ViktorHofer
Copy link
Member

ViktorHofer commented Aug 30, 2019

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

@karelz karelz assigned alnikola and wfurt and unassigned alnikola Dec 5, 2019
@karelz
Copy link
Member

karelz commented Dec 5, 2019

Triage: We should check why it regressed recently
@wfurt please check if it reproduced in the past and if it will be impacted by your SSL changes.

@msftgits msftgits transferred this issue from dotnet/corefx Feb 1, 2020
@msftgits msftgits added this to the 5.0 milestone Feb 1, 2020
@wfurt wfurt changed the title System.Net.Security.Tests.ApmSslStreamSystemDefaultTest.ClientAndServer_OneOrBothUseDefault_Ok failed in CI System.Net.Security.Tests.ApmSslStreamSystemDefaultTest.ClientAndServer_OneOrBothUseDefault_Ok failed in CI with ObjectDisposedException Feb 6, 2020
@jkotas
Copy link
Member

jkotas commented Mar 17, 2020

Hit in #33664

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

Log :

    System.Net.Security.Tests.ApmSslStreamSystemDefaultTest.ClientAndServer_OneOrBothUseDefault_Ok(clientProtocols: Default, serverProtocols: Ssl2 | Default | Tls11 | Tls12) [FAIL]
      System.ObjectDisposedException : Safe handle has been closed.
      Object name: 'SafeHandle'.
      Stack Trace:
        /_/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/SafeHandle.cs(149,0): at System.Runtime.InteropServices.SafeHandle.DangerousAddRef(Boolean& success)
        /_/src/libraries/Common/src/Interop/Windows/SspiCli/SecuritySafeHandles.cs(354,0): at System.Net.Security.SafeCredentialReference..ctor(SafeFreeCredentials target)
        /_/src/libraries/Common/src/Interop/Windows/SspiCli/SecuritySafeHandles.cs(341,0): at System.Net.Security.SafeCredentialReference.CreateReference(SafeFreeCredentials target)
        /_/src/libraries/System.Net.Security/src/System/Net/Security/SslSessionsCache.cs(201,0): at System.Net.Security.SslSessionsCache.CacheCredential(SafeFreeCredentials creds, Byte[] thumbPrint, SslProtocols sslProtocols, Boolean isServer, EncryptionPolicy encryptionPolicy)
        /_/src/libraries/System.Net.Security/src/System/Net/Security/SecureChannel.cs(830,0): at System.Net.Security.SecureChannel.GenerateToken(ReadOnlySpan`1 inputBuffer, Byte[]& output)
        /_/src/libraries/System.Net.Security/src/System/Net/Security/SecureChannel.cs(734,0): at System.Net.Security.SecureChannel.NextMessage(ReadOnlySpan`1 incomingBuffer)
        /_/src/libraries/System.Net.Security/src/System/Net/Security/SslStream.Implementation.cs(375,0): at System.Net.Security.SslStream.ProcessBlob(Int32 frameSize)
        /_/src/libraries/System.Net.Security/src/System/Net/Security/SslStream.Implementation.cs(342,0): at System.Net.Security.SslStream.ReceiveBlobAsync[TIOAdapter](TIOAdapter adapter)
        /_/src/libraries/System.Net.Security/src/System/Net/Security/SslStream.Implementation.cs(268,0): at System.Net.Security.SslStream.ForceAuthenticationAsync[TIOAdapter](TIOAdapter adapter, Boolean receiveFirst, Byte[] reAuthenticationData, Boolean isApm)
        /_/src/libraries/Common/src/System/Threading/Tasks/TaskToApm.cs(42,0): at System.Threading.Tasks.TaskToApm.End(IAsyncResult asyncResult)
        /_/src/libraries/System.Net.Security/src/System/Net/Security/SslStream.cs(233,0): at System.Net.Security.SslStream.EndAuthenticateAsClient(IAsyncResult asyncResult)
        /_/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/FutureFactory.cs(513,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 ---
        /_/src/libraries/Common/tests/System/Threading/Tasks/TaskTimeoutExtensions.cs(83,0): at System.Threading.Tasks.TaskTimeoutExtensions.WhenAllOrAnyFailed(Task[] tasks)
        /_/src/libraries/Common/tests/System/Threading/Tasks/TaskTimeoutExtensions.cs(111,0): at System.Threading.Tasks.TaskTimeoutExtensions.WhenAllOrAnyFailed(Task[] tasks)
        /_/src/libraries/Common/tests/System/Threading/Tasks/TaskTimeoutExtensions.cs(71,0): at System.Threading.Tasks.TaskTimeoutExtensions.WhenAllOrAnyFailed(Task[] tasks, Int32 millisecondsTimeout)
        /_/src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamSystemDefaultsTest.cs(60,0): at System.Net.Security.Tests.SslStreamSystemDefaultTest.ClientAndServer_OneOrBothUseDefault_Ok(Nullable`1 clientProtocols, Nullable`1 serverProtocols)
        --- End of stack trace from previous location ---
    System.Net.Security.Tests.SyncSslStreamSystemDefaultTest.ClientAndServer_OneOrBothUseDefault_Ok(clientProtocols: Ssl2 | Default | Tls11 | Tls12, serverProtocols: Default) [FAIL]
      System.NullReferenceException : Object reference not set to an instance of an object.
      Stack Trace:
        /_/src/libraries/System.Net.Security/src/System/Net/Security/SslSessionsCache.cs(199,0): at System.Net.Security.SslSessionsCache.CacheCredential(SafeFreeCredentials creds, Byte[] thumbPrint, SslProtocols sslProtocols, Boolean isServer, EncryptionPolicy encryptionPolicy)
        /_/src/libraries/System.Net.Security/src/System/Net/Security/SecureChannel.cs(830,0): at System.Net.Security.SecureChannel.GenerateToken(ReadOnlySpan`1 inputBuffer, Byte[]& output)
        /_/src/libraries/System.Net.Security/src/System/Net/Security/SecureChannel.cs(726,0): at System.Net.Security.SecureChannel.NextMessage(ReadOnlySpan`1 incomingBuffer)
        /_/src/libraries/System.Net.Security/src/System/Net/Security/SslStream.Implementation.cs(375,0): at System.Net.Security.SslStream.ProcessBlob(Int32 frameSize)
        /_/src/libraries/System.Net.Security/src/System/Net/Security/SslStream.Implementation.cs(342,0): at System.Net.Security.SslStream.ReceiveBlobAsync[TIOAdapter](TIOAdapter adapter)
        /_/src/libraries/System.Net.Security/src/System/Net/Security/SslStream.Implementation.cs(268,0): at System.Net.Security.SslStream.ForceAuthenticationAsync[TIOAdapter](TIOAdapter adapter, Boolean receiveFirst, Byte[] reAuthenticationData, Boolean isApm)
        /_/src/libraries/System.Net.Security/src/System/Net/Security/SslStream.Implementation.cs(208,0): at System.Net.Security.SslStream.ProcessAuthentication(Boolean isAsync, Boolean isApm, CancellationToken cancellationToken)
        /_/src/libraries/System.Net.Security/src/System/Net/Security/SslStream.cs(345,0): at System.Net.Security.SslStream.AuthenticateAsServer(SslServerAuthenticationOptions sslServerAuthenticationOptions)
        /_/src/libraries/System.Net.Security/src/System/Net/Security/SslStream.cs(337,0): at System.Net.Security.SslStream.AuthenticateAsServer(X509Certificate serverCertificate, Boolean clientCertificateRequired, SslProtocols enabledSslProtocols, Boolean checkCertificateRevocation)
        /_/src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamSystemDefaultsTest.cs(164,0): at System.Net.Security.Tests.SyncSslStreamSystemDefaultTest.<>c__DisplayClass1_0.<AuthenticateServerAsync>b__0()
        /_/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs(2364,0): at System.Threading.Tasks.Task.InnerInvoke()
        /_/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs(2350,0): at System.Threading.Tasks.Task.<>c.<.cctor>b__274_0(Object obj)
        /_/src/libraries/System.Private.CoreLib/src/System/Threading/ExecutionContext.cs(289,0): at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
        --- End of stack trace from previous location ---
        /_/src/libraries/System.Private.CoreLib/src/System/Threading/ExecutionContext.cs(314,0): at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
        /_/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs(2314,0): at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
        --- End of stack trace from previous location ---
        /_/src/libraries/Common/tests/System/Threading/Tasks/TaskTimeoutExtensions.cs(83,0): at System.Threading.Tasks.TaskTimeoutExtensions.WhenAllOrAnyFailed(Task[] tasks)
        /_/src/libraries/Common/tests/System/Threading/Tasks/TaskTimeoutExtensions.cs(111,0): at System.Threading.Tasks.TaskTimeoutExtensions.WhenAllOrAnyFailed(Task[] tasks)
        /_/src/libraries/Common/tests/System/Threading/Tasks/TaskTimeoutExtensions.cs(71,0): at System.Threading.Tasks.TaskTimeoutExtensions.WhenAllOrAnyFailed(Task[] tasks, Int32 millisecondsTimeout)
        /_/src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamSystemDefaultsTest.cs(60,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

@v-haren
Copy link

v-haren commented Oct 28, 2020

failed again in job: runtime 20201027.54

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

net6.0-Windows_NT-Release-x64-CoreCLR_release-Windows.81.Amd64.Open

Error message

System.ObjectDisposedException : Safe handle has been closed.
Object name: 'SafeHandle'.


Stack trace
   at System.Runtime.InteropServices.SafeHandle.DangerousAddRef(Boolean& success) in /_/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/SafeHandle.cs:line 148
   at System.Net.Security.SafeCredentialReference..ctor(SafeFreeCredentials target) in /_/src/libraries/Common/src/Interop/Windows/SspiCli/SecuritySafeHandles.cs:line 353
   at System.Net.Security.SafeCredentialReference.CreateReference(SafeFreeCredentials target) in /_/src/libraries/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/libraries/System.Net.Security/src/System/Net/Security/SslSessionsCache.cs:line 197
   at System.Net.Security.SecureChannel.GenerateToken(ReadOnlySpan`1 inputBuffer, Byte[]& output) in /_/src/libraries/System.Net.Security/src/System/Net/Security/SecureChannel.cs:line 819
   at System.Net.Security.SecureChannel.NextMessage(ReadOnlySpan`1 incomingBuffer) in /_/src/libraries/System.Net.Security/src/System/Net/Security/SecureChannel.cs:line 727
   at System.Net.Security.SslStream.ProcessBlob(Int32 frameSize) in /_/src/libraries/System.Net.Security/src/System/Net/Security/SslStream.Implementation.cs:line 577
   at System.Net.Security.SslStream.ReceiveBlobAsync[TIOAdapter](TIOAdapter adapter) in /_/src/libraries/System.Net.Security/src/System/Net/Security/SslStream.Implementation.cs:line 539
   at System.Net.Security.SslStream.ForceAuthenticationAsync[TIOAdapter](TIOAdapter adapter, Boolean receiveFirst, Byte[] reAuthenticationData, Boolean isApm) in /_/src/libraries/System.Net.Security/src/System/Net/Security/SslStream.Implementation.cs:line 356
   at System.Threading.Tasks.TaskToApm.End(IAsyncResult asyncResult) in /_/src/libraries/Common/src/System/Threading/Tasks/TaskToApm.cs:line 42
   at System.Net.Security.SslStream.EndAuthenticateAsClient(IAsyncResult asyncResult) in /_/src/libraries/System.Net.Security/src/System/Net/Security/SslStream.cs:line 212
   at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization) in /_/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/FutureFactory.cs:line 512
--- End of stack trace from previous location ---
   at System.Threading.Tasks.TaskTimeoutExtensions.WhenAllOrAnyFailed(Task[] tasks) in /_/src/libraries/Common/tests/System/Threading/Tasks/TaskTimeoutExtensions.cs:line 96
   at System.Threading.Tasks.TaskTimeoutExtensions.WhenAllOrAnyFailed(Task[] tasks) in /_/src/libraries/Common/tests/System/Threading/Tasks/TaskTimeoutExtensions.cs:line 124
   at System.Threading.Tasks.TaskTimeoutExtensions.WhenAllOrAnyFailed(Task[] tasks, Int32 millisecondsTimeout) in /_/src/libraries/Common/tests/System/Threading/Tasks/TaskTimeoutExtensions.cs:line 84
   at System.Net.Security.Tests.SslStreamSystemDefaultTest.ClientAndServer_OneOrBothUseDefault_Ok(Nullable`1 clientProtocols, Nullable`1 serverProtocols) in /_/src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamSystemDefaultsTest.cs:line 85
--- End of stack trace from previous location ---

@wfurt
Copy link
Member

wfurt commented Oct 28, 2020

cc: @aik-jahoda

@v-haren

This comment has been minimized.

@v-haren

This comment has been minimized.

@VincentBu
Copy link
Contributor

Failed again in run runtime 20210207.5

Failed test:

net6.0-windows-Release-x86-CoreCLR_checked-Windows.10.Amd64.Open
  -System.Net.Security.Tests.SyncSslStreamSystemDefaultTest.ClientAndServer_OneOrBothUseDefault_Ok(clientProtocols: Tls11, serverProtocols: Tls | Tls11 | Tls12)

Error message:

System.ObjectDisposedException : Safe handle has been closed.
Object name: 'SafeHandle'.


Stack trace
   at System.Runtime.InteropServices.SafeHandle.DangerousAddRef(Boolean& success) in /_/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/SafeHandle.cs:line 148
   at System.Net.Security.SafeCredentialReference..ctor(SafeFreeCredentials target) in /_/src/libraries/Common/src/System/Net/Security/SafeCredentialReference.cs:line 35
   at System.Net.Security.SafeCredentialReference.CreateReference(SafeFreeCredentials target) in /_/src/libraries/Common/src/System/Net/Security/SafeCredentialReference.cs:line 27
   at System.Net.Security.SslSessionsCache.<CacheCredential>g__ShrinkCredentialCache|5_0() in /_/src/libraries/System.Net.Security/src/System/Net/Security/SslSessionsCache.cs:line 224
   at System.Net.Security.SslSessionsCache.CacheCredential(SafeFreeCredentials creds, Byte[] thumbPrint, SslProtocols sslProtocols, Boolean isServer, EncryptionPolicy encryptionPolicy) in /_/src/libraries/System.Net.Security/src/System/Net/Security/SslSessionsCache.cs:line 182
   at System.Net.Security.SecureChannel.GenerateToken(ReadOnlySpan`1 inputBuffer, Byte[]& output) in /_/src/libraries/System.Net.Security/src/System/Net/Security/SecureChannel.cs:line 819
   at System.Net.Security.SecureChannel.NextMessage(ReadOnlySpan`1 incomingBuffer) in /_/src/libraries/System.Net.Security/src/System/Net/Security/SecureChannel.cs:line 727
   at System.Net.Security.SslStream.ProcessBlob(Int32 frameSize) in /_/src/libraries/System.Net.Security/src/System/Net/Security/SslStream.Implementation.cs:line 577
   at System.Net.Security.SslStream.ReceiveBlobAsync[TIOAdapter](TIOAdapter adapter) in /_/src/libraries/System.Net.Security/src/System/Net/Security/SslStream.Implementation.cs:line 539
   at System.Net.Security.SslStream.ForceAuthenticationAsync[TIOAdapter](TIOAdapter adapter, Boolean receiveFirst, Byte[] reAuthenticationData, Boolean isApm) in /_/src/libraries/System.Net.Security/src/System/Net/Security/SslStream.Implementation.cs:line 356
   at System.Net.Security.SslStream.ProcessAuthentication(Boolean isAsync, Boolean isApm, CancellationToken cancellationToken) in /_/src/libraries/System.Net.Security/src/System/Net/Security/SslStream.Implementation.cs:line 215
   at System.Net.Security.SslStream.AuthenticateAsClient(SslClientAuthenticationOptions sslClientAuthenticationOptions) in /_/src/libraries/System.Net.Security/src/System/Net/Security/SslStream.cs:line 297
   at System.Net.Security.SslStream.AuthenticateAsClient(String targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, Boolean checkCertificateRevocation) in /_/src/libraries/System.Net.Security/src/System/Net/Security/SslStream.cs:line 283
   at System.Net.Security.Tests.SyncSslStreamSystemDefaultTest.<>c__DisplayClass0_0.<AuthenticateClientAsync>b__0() in /_/src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamSystemDefaultsTest.cs:line 178
   at System.Threading.Tasks.Task.InnerInvoke() in /_/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs:line 2381
   at System.Threading.Tasks.Task.<>c.<.cctor>b__278_0(Object obj) in /_/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs:line 2367
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state) in /_/src/libraries/System.Private.CoreLib/src/System/Threading/ExecutionContext.cs:line 277
--- End of stack trace from previous location ---
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state) in /_/src/libraries/System.Private.CoreLib/src/System/Threading/ExecutionContext.cs:line 302
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread) in /_/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs:line 2331
--- End of stack trace from previous location ---
   at System.Threading.Tasks.TaskTimeoutExtensions.WhenAllOrAnyFailed(Task[] tasks) in /_/src/libraries/Common/tests/System/Threading/Tasks/TaskTimeoutExtensions.cs:line 96
   at System.Threading.Tasks.TaskTimeoutExtensions.WhenAllOrAnyFailed(Task[] tasks) in /_/src/libraries/Common/tests/System/Threading/Tasks/TaskTimeoutExtensions.cs:line 124
   at System.Threading.Tasks.TaskTimeoutExtensions.WhenAllOrAnyFailed(Task[] tasks, Int32 millisecondsTimeout) in /_/src/libraries/Common/tests/System/Threading/Tasks/TaskTimeoutExtensions.cs:line 84
   at System.Net.Security.Tests.SslStreamSystemDefaultTest.ClientAndServer_OneOrBothUseDefault_Ok(Nullable`1 clientProtocols, Nullable`1 serverProtocols) in /_/src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamSystemDefaultsTest.cs:line 86
--- End of stack trace from previous location ---

@VincentBu

This comment has been minimized.

@VincentBu

This comment has been minimized.

@VincentBu

This comment has been minimized.

@VincentBu

This comment has been minimized.

@karelz
Copy link
Member

karelz commented May 12, 2021

Failures during 3/12-9/6 (incl. PRs):

Date Build / PR OS
3/13 PR #49543 Windows.10.Amd64.Server19H1.ES.Open
3/15 PR #49532 Windows.10.Amd64.Server19H1.Open
3/30 jitstress_tiered Windows.10.Arm64v8.Open
4/14 PR #50097 Windows.10.Amd64.Open
4/19 PR #51237 Windows.10.Amd64.Server19H1.ES.Open
4/20 PR #51528 Windows.10.Amd64.Server19H1.Open
4/20 jitstress2_tiered Windows.10.Arm64v8.Open
4/27 Official run Windows.10.Amd64.ServerRS5.Open
5/1 PR #52165 Windows.10.Amd64.Server19H1.Open
5/12 jitminopts Windows.10.Amd64.Open
5/14 PR #52757 Windows.10.Amd64.Open
5/23 jitstress1_tiered Windows.10.Arm64v8.Open
5/27 PR #53315 Windows.10.Amd64.Open
6/2 PR #53570 Windows.10.Amd64.Open
6/4 Official run Windows.10.Amd64.Open
6/8 tailcallstress Windows.10.Amd64.Open
6/11 PR #53739 Windows.10.Amd64.Open
6/28 PR #54544 Windows.10.Amd64.Open
6/30 Official run Windows.81.Amd64.Open
7/6 PR #55229 Windows.10.Amd64.Open
7/10 jitstress2_tiered Windows.10.Arm64v8.Open
7/30 PR #56651 Windows.10.Arm64v8.Open
7/31 jitstress2_jitstressregs0x1000 Windows.10.Amd64.Open
8/16 PR #57282 - jitminopts Windows.10.Arm64v8.Open
8/27 jitstress2_tiered Windows.10.Arm64v8.Open
8/30 PR #58314 Windows.Nano.1809.Amd64.Open
9/3 PR #58552 Windows.10.Amd64.Open
9/3 PR #58648 Windows.10.Amd64.Open
9/5 fullpgo Windows.10.Amd64.Open

@karelz karelz changed the title System.Net.Security.Tests.ApmSslStreamSystemDefaultTest.ClientAndServer_OneOrBothUseDefault_Ok failed in CI with ObjectDisposedException ClientAndServer_OneOrBothUseDefault_Ok failed in CI with ObjectDisposedException May 12, 2021
@karelz karelz modified the milestones: Future, 6.0.0 May 12, 2021
@VincentBu

This comment has been minimized.

@VincentBu

This comment has been minimized.

@ManickaP
Copy link
Member

Triage: we lived with this for a while, we'll survive for a bit longer.

@ManickaP ManickaP modified the milestones: 6.0.0, Future Aug 10, 2021
@karelz karelz modified the milestones: Future, 7.0.0 Aug 13, 2021
@wfurt wfurt self-assigned this Aug 25, 2021
@wfurt
Copy link
Member

wfurt commented Aug 25, 2021

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

This was referenced Sep 2, 2021
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Sep 2, 2021
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Sep 9, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Oct 9, 2021
@wfurt wfurt reopened this Nov 2, 2021
@dotnet dotnet unlocked this conversation Nov 4, 2021
@karelz
Copy link
Member

karelz commented Nov 4, 2021

@wfurt can you please add few details why it was reopened? I assume you reverted the changes ...

@wfurt
Copy link
Member

wfurt commented Nov 4, 2021

yes, #58594 was reverted in PR #61069

@rzikm
Copy link
Member

rzikm commented May 30, 2022

No recent hits in the test DB, closing until this resurfaces.

@rzikm rzikm closed this as completed May 30, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Jun 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.