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

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

Closed
runfoapp bot opened this issue Jan 8, 2021 · 13 comments · Fixed by #58594
Closed

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

runfoapp bot opened this issue Jan 8, 2021 · 13 comments · Fixed by #58594
Labels
area-System.Net.Security bug test-run-core Test failures in .NET Core test runs
Milestone

Comments

@runfoapp
Copy link

runfoapp bot commented Jan 8, 2021

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

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)windows.10.amd64.serverrs5.open@mcr.microsoft.com/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)windows.10.amd64.serverrs5.open@mcr.microsoft.com/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
@Dotnet-GitSync-Bot
Copy link
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.

@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added the untriaged New issue has not been triaged by the area owner label Jan 8, 2021
@hoyosjs hoyosjs changed the title Tracking issue in roslyn-ci Safe handle use after close in System.Net.Security.Tests Jan 8, 2021
@ghost
Copy link

ghost commented Jan 8, 2021

Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

Issue Details

Runfo Tracking Issue: Tracking issue in roslyn-ci

Build Definition Kind Run Name
941002 runtime Rolling net6.0-windows-Release-x64-CoreCLR_release-Windows.81.Amd64.Open
940338 runtime PR 46343 net6.0-windows-Release-x86-CoreCLR_release-Windows.10.Amd64.Server19H1.ES.Open

Build Result Summary

Day Hit Count Week Hit Count Month Hit Count
0 2 2
Author: runfoapp[bot]
Assignees: -
Labels:

area-System.Net.Security, untriaged

Milestone: -

@wfurt
Copy link
Member

wfurt commented Jan 8, 2021

cc: @aik-jahoda

@karelz karelz removed the untriaged New issue has not been triaged by the area owner label Feb 2, 2021
@karelz karelz added this to the 6.0.0 milestone Feb 2, 2021
@karelz karelz added the bug label Feb 2, 2021
@ManickaP
Copy link
Member

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

@ManickaP
Copy link
Member

Triage: punting as #30724

@ManickaP ManickaP modified the milestones: 6.0.0, Future Aug 10, 2021
@karelz karelz modified the milestones: Future, 7.0.0 Aug 13, 2021
@karelz karelz added the test-run-core Test failures in .NET Core test runs label Aug 13, 2021
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Sep 3, 2021
@wfurt wfurt self-assigned this Sep 3, 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

@karelz
Copy link
Member

karelz commented Nov 4, 2021

@wfurt which PR reverted it? Is it linked?

Answer: #58594 was reverted in PR #61069

@wfurt
Copy link
Member

wfurt commented Mar 24, 2022

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

@rzikm
Copy link
Member

rzikm commented Mar 25, 2022

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

@wfurt
Copy link
Member

wfurt commented Mar 25, 2022

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.

@karelz
Copy link
Member

karelz commented Mar 29, 2022

Agreed. Closing per above - no recent hits.

@karelz karelz closed this as completed Mar 29, 2022
@wfurt
Copy link
Member

wfurt commented Mar 29, 2022

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.

@ghost ghost locked as resolved and limited conversation to collaborators Apr 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Net.Security bug test-run-core Test failures in .NET Core test runs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants