Skip to content

Safe handle use after close in System.Net.Security.Tests #46770

Closed

Description

@runfoapp

Failures 5/27-7/27 (incl. PRs):

Day Run OS Test
5/28 PR #53433 Windows.10.Amd64.Open ServerAsyncAuthenticate_SniSetVersion_Success
6/2 PR #53570 Windows.10.Amd64.Open ClientAndServer_OneOrBothUseDefault_Ok
6/4 Official run Windows.10.Amd64.Open ClientAndServer_OneOrBothUseDefault_Ok
6/8 tailcallstress Windows.10.Amd64.Open ClientAndServer_OneOrBothUseDefault_Ok
6/11 PR #53739 Windows.10.Amd64.Open ClientAndServer_OneOrBothUseDefault_Ok
6/28 PR #54544 Windows.10.Amd64.Open ClientAndServer_OneOrBothUseDefault_Ok
6/30 Official run Windows.81.Amd64.Open ClientAndServer_OneOrBothUseDefault_Ok
7/6 PR #55203 Windows.10.Amd64.Server19H1.ES.Open ClientAsyncAuthenticate_ServerNoEncryption_NoConnect
7/6 PR #55229 Windows.10.Amd64.Open ClientAndServer_OneOrBothUseDefault_Ok
7/10 jitstress2_tiered Windows.10.Arm64v8.Open ClientAndServer_OneOrBothUseDefault_Ok
7/14 PR #55641 Windows.Nano.1809.Amd64.Open ClientAsyncAuthenticate_ServerNoEncryption_NoConnect
7/15 Official run Windows.10.Amd64.Server19H1.Open ClientAsyncAuthenticate_IndividualServerVsAllClientSupportedProtocols_Success
7/20 PR #56043 Windows.10.Amd64.Server19H1.ES.Open ZeroByteRead_PerformsZeroByteReadOnUnderlyingStreamWhenDataNeeded

Latest ClientAndServer_OneOrBothUseDefault_OkClientAndServer_OneOrBothUseDefault_Ok tracking in #30724 (comment)

Typical failure:

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

   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 33
   at System.Net.Security.SafeCredentialReference.CreateReference(SafeFreeCredentials target) in /_/src/libraries/Common/src/System/Net/Security/SafeCredentialReference.cs:line 25
   at System.Net.Security.SslSessionsCache.<CacheCredential>g__ShrinkCredentialCache|5_0() in /_/src/libraries/System.Net.Security/src/System/Net/Security/SslSessionsCache.cs:line 225
   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 823
   at System.Net.Security.SecureChannel.NextMessage(ReadOnlySpan`1 incomingBuffer) in /_/src/libraries/System.Net.Security/src/System/Net/Security/SecureChannel.cs:line 731
   at System.Net.Security.SslStream.ProcessBlob(Int32 frameSize) in /_/src/libraries/System.Net.Security/src/System/Net/Security/SslStream.Implementation.cs:line 579
   at System.Net.Security.SslStream.ReceiveBlobAsync[TIOAdapter](TIOAdapter adapter) in /_/src/libraries/System.Net.Security/src/System/Net/Security/SslStream.Implementation.cs:line 541
   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 358
   at System.Threading.Tasks.TaskToApm.End(IAsyncResult asyncResult) in /_/src/libraries/Common/src/System/Threading/Tasks/TaskToApm.cs:line 41
   at System.Net.Security.SslStream.EndAuthenticateAsClient(IAsyncResult asyncResult) in /_/src/libraries/System.Net.Security/src/System/Net/Security/SslStream.cs:line 211
   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 511
--- 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 55
   at System.Threading.Tasks.TaskTimeoutExtensions.WhenAllOrAnyFailed(Task[] tasks) in /_/src/libraries/Common/tests/System/Threading/Tasks/TaskTimeoutExtensions.cs:line 82
   at System.Threading.Tasks.TaskTimeoutExtensions.WhenAllOrAnyFailed(Task[] tasks, Int32 millisecondsTimeout) in /_/src/libraries/Common/tests/System/Threading/Tasks/TaskTimeoutExtensions.cs:line 49
   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 ---

Details from runfo - seems to be invalid link

Details Runfo Tracking Issue: [Safe handle use after close in System.Net.Security.Tests](https://runfo.azurewebsites.net/tracking/issue/61) |Build|Definition|Kind|Run Name|Console|Core Dump|Test Results|Run Client| |---|---|---|---|---|---|---|---| |[1341729](https://dev.azure.com/dnceng/public/_build/results?buildId=1341729)|[runtime](https://dnceng.visualstudio.com/public/_build?definitionId=686)|[PR 58648](https://github.com//pull/58648)|net6.0-windows-Debug-x64-CoreCLR_checked-Windows.10.Amd64.Open|[console.log](https://helixre8s23ayyeko0k025g8.blob.core.windows.net/dotnet-runtime-refs-pull-58648-merge-a61c4d577d0049f581/System.Net.Security.Tests/1/console.e318ac2f.log?%3F%253Fsv%253D2019-07-07%2526se%253D2021-09-23T19%25253A41%25253A14Z%2526sr%253Dc%2526sp%253Drl%2526sig%253DKEOEvxZ%25252Fv0PibRTudT%25252Bf5oEGY7tWdHf%25252BY9cOWI5XI3U%25253D)|||[runclient.py](https://helixre8s23ayyeko0k025g8.blob.core.windows.net/dotnet-runtime-refs-pull-58648-merge-a61c4d577d0049f581/System.Net.Security.Tests/73a0e020-fa6e-4fa6-84f9-fb521c436444.log?%3F%253Fsv%253D2019-07-07%2526se%253D2021-09-23T19%25253A41%25253A14Z%2526sr%253Dc%2526sp%253Drl%2526sig%253DKEOEvxZ%25252Fv0PibRTudT%25252Bf5oEGY7tWdHf%25252BY9cOWI5XI3U%25253D)| |[1340724](https://dev.azure.com/dnceng/public/_build/results?buildId=1340724)|[runtime](https://dnceng.visualstudio.com/public/_build?definitionId=686)|[PR 58552](https://github.com//pull/58552)|net6.0-windows-Debug-x64-CoreCLR_checked-Windows.10.Amd64.Open|[console.log](https://helixre8s23ayyeko0k025g8.blob.core.windows.net/dotnet-runtime-refs-pull-58552-merge-8b9a5b30426b4a36a5/System.Net.Security.Tests/1/console.8bbad732.log?%3F%253Fsv%253D2019-07-07%2526se%253D2021-09-23T12%25253A40%25253A35Z%2526sr%253Dc%2526sp%253Drl%2526sig%253D4R%25252BY3LZ6kewi1dvVhgpCHKkBPVY%25252Fr5TZLEcYyIdXYqY%25253D)|||[runclient.py](https://helixre8s23ayyeko0k025g8.blob.core.windows.net/dotnet-runtime-refs-pull-58552-merge-8b9a5b30426b4a36a5/System.Net.Security.Tests/ffe957e0-c5f4-4d6a-9563-2fbcff5dcf94.log?%3F%253Fsv%253D2019-07-07%2526se%253D2021-09-23T12%25253A40%25253A35Z%2526sr%253Dc%2526sp%253Drl%2526sig%253D4R%25252BY3LZ6kewi1dvVhgpCHKkBPVY%25252Fr5TZLEcYyIdXYqY%25253D)| |[1337750](https://dev.azure.com/dnceng/public/_build/results?buildId=1337750)|[runtime](https://dnceng.visualstudio.com/public/_build?definitionId=686)|[PR 58557](https://github.com//pull/58557)|net6.0-windows-Debug-x64-CoreCLR_release-(Windows.Nano.1809.Amd64.Open)[email protected]/dotnet-buildtools/prereqs:nanoserver-1809-helix-amd64-08e8e40-20200107182504|[console.log](https://helixre8s23ayyeko0k025g8.blob.core.windows.net/dotnet-runtime-refs-pull-58557-merge-022dd8becab04fc485/System.Net.Security.Tests/1/console.3905b6aa.log?%3F%253Fsv%253D2019-07-07%2526se%253D2021-09-22T14%25253A32%25253A19Z%2526sr%253Dc%2526sp%253Drl%2526sig%253DXW1QVvWwk%25252BJ7LtUYeX16qovgGcl9kWrt2Q%25252BMnUC5IIs%25253D)|||[runclient.py](https://helixre8s23ayyeko0k025g8.blob.core.windows.net/dotnet-runtime-refs-pull-58557-merge-022dd8becab04fc485/System.Net.Security.Tests/8944cb85-960f-4047-8445-628fb9af5a45.log?%3F%253Fsv%253D2019-07-07%2526se%253D2021-09-22T14%25253A32%25253A19Z%2526sr%253Dc%2526sp%253Drl%2526sig%253DXW1QVvWwk%25252BJ7LtUYeX16qovgGcl9kWrt2Q%25252BMnUC5IIs%25253D)| |[1328368](https://dev.azure.com/dnceng/public/_build/results?buildId=1328368)|[runtime](https://dnceng.visualstudio.com/public/_build?definitionId=686)|[PR 58314](https://github.com//pull/58314)|net6.0-windows-Debug-x64-CoreCLR_release-(Windows.Nano.1809.Amd64.Open)[email protected]/dotnet-buildtools/prereqs:nanoserver-1809-helix-amd64-08e8e40-20200107182504|[console.log](https://helixre8s23ayyeko0k025g8.blob.core.windows.net/dotnet-runtime-refs-pull-58314-merge-b15da51a3b6141d186/System.Net.Security.Tests/1/console.262fef71.log?%3F%253Fsv%253D2019-07-07%2526se%253D2021-09-19T14%25253A59%25253A44Z%2526sr%253Dc%2526sp%253Drl%2526sig%253DwJ9KTTm5WpJ4l08zW5qid6fVk7O6NEhrAwXtuPsQ7PQ%25253D)|||[runclient.py](https://helixre8s23ayyeko0k025g8.blob.core.windows.net/dotnet-runtime-refs-pull-58314-merge-b15da51a3b6141d186/System.Net.Security.Tests/d3eb5c45-7c75-47e6-98d1-2efaa1e33397.log?%3F%253Fsv%253D2019-07-07%2526se%253D2021-09-19T14%25253A59%25253A44Z%2526sr%253Dc%2526sp%253Drl%2526sig%253DwJ9KTTm5WpJ4l08zW5qid6fVk7O6NEhrAwXtuPsQ7PQ%25253D)| |[1288413](https://dev.azure.com/dnceng/public/_build/results?buildId=1288413)|[runtime](https://dnceng.visualstudio.com/public/_build?definitionId=686)|[PR 57226](https://github.com//pull/57226)|net5.0-Windows_NT-Debug-x64-CoreCLR_checked-Windows.10.Amd64.Open|[console.log](https://helixre8s23ayyeko0k025g8.blob.core.windows.net/dotnet-runtime-refs-pull-57226-merge-ac2dca0bbef84f3f80/System.Net.Security.Tests/1/console.2cb82408.log?%3F%253Fsv%253D2019-07-07%2526se%253D2021-08-31T19%25253A25%25253A50Z%2526sr%253Dc%2526sp%253Drl%2526sig%253Dp8HVkoggom%25252BHeGf3yIHWNc8VsGHJW19WZ%25252FzVEunBuCk%25253D)||[test results](https://helixre8s23ayyeko0k025g8.blob.core.windows.net/dotnet-runtime-refs-pull-57226-merge-ac2dca0bbef84f3f80/System.Net.Security.Tests/testResults.xml?%3F%253Fsv%253D2019-07-07%2526se%253D2021-08-31T19%25253A25%25253A50Z%2526sr%253Dc%2526sp%253Drl%2526sig%253Dp8HVkoggom%25252BHeGf3yIHWNc8VsGHJW19WZ%25252FzVEunBuCk%25253D)|[runclient.py](https://helixre8s23ayyeko0k025g8.blob.core.windows.net/dotnet-runtime-refs-pull-57226-merge-ac2dca0bbef84f3f80/System.Net.Security.Tests/d8167a56-5495-4982-ae96-789a88c98fe8.log?%3F%253Fsv%253D2019-07-07%2526se%253D2021-08-31T19%25253A25%25253A50Z%2526sr%253Dc%2526sp%253Drl%2526sig%253Dp8HVkoggom%25252BHeGf3yIHWNc8VsGHJW19WZ%25252FzVEunBuCk%25253D)|

Build Result Summary

Day Hit Count Week Hit Count Month Hit Count
0 2 5

Activity

  1. Dotnet-GitSync-Bot commented on Jan 8, 2021

    @Dotnet-GitSync-Bot
    Collaborator

    I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

  2. changed the title [-]Tracking issue in roslyn-ci[/-] [+]Safe handle use after close in System.Net.Security.Tests[/+] on Jan 8, 2021
  3. wfurt commented on Jan 8, 2021

    @wfurt
    Member
  4. removed
    untriagedNew issue has not been triaged by the area owner
    on Feb 2, 2021
  5. added this to the 6.0.0 milestone on Feb 2, 2021
  6. ManickaP commented on Aug 10, 2021

    @ManickaP
    Member

    Is this the same thing as #30724??? If, we should merge the issues into one.

  7. ManickaP commented on Aug 10, 2021

    @ManickaP
    Member

    Triage: punting as #30724

  8. modified the milestones: 6.0.0, Future on Aug 10, 2021
  9. 6 remaining items

  10. ghost removed
    in-prThere is an active PR which will close this issue when it is merged
    on Sep 9, 2021
  11. ghost locked as resolved and limited conversation to collaborators on Oct 9, 2021
  12. reopened this on Nov 2, 2021
  13. unlocked this conversation on Nov 4, 2021
  14. karelz commented on Nov 4, 2021

    @karelz
    Member

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

  15. wfurt commented on Nov 4, 2021

    @wfurt
    Member

    yes, #58594 was reverted

  16. karelz commented on Nov 4, 2021

    @karelz
    Member

    @wfurt which PR reverted it? Is it linked?

    Answer: #58594 was reverted in PR #61069

  17. removed their assignment
    on Mar 24, 2022
  18. wfurt commented on Mar 24, 2022

    @wfurt
    Member

    Do we know home much this is still happening @rzikm ? From the label it does not seem we disabled the tests.

  19. rzikm commented on Mar 25, 2022

    @rzikm
    Member

    @wfurt, I don't see any recent hits in the CI results DB. Do we close the issue then?

  20. wfurt commented on Mar 25, 2022

    @wfurt
    Member

    It somewhat worries me that it is magical fixed but I see no benefit of keeping it open.
    So I would close it unless @karelz disagree.

  21. karelz commented on Mar 29, 2022

    @karelz
    Member

    Agreed. Closing per above - no recent hits.

  22. wfurt commented on Mar 29, 2022

    @wfurt
    Member

    One more thought on this: we generally eliminated all the tests that could dispose SslStream during use. I'm wondering if that is what triggers this pattern. And it would explain why we don't see field reports.
    The other change mad to this test was to check supported protocols and avoid cases where we force something not supported by OS.

  23. ghost locked as resolved and limited conversation to collaborators on Apr 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions