Skip to content

Handle StreamBuffer disposal race in SslStream test - #133021

Open
rzikm wants to merge 1 commit into
dotnet:mainfrom
rzikm:rzikm/fix-sslstream-dispose-test
Open

Handle StreamBuffer disposal race in SslStream test#133021
rzikm wants to merge 1 commit into
dotnet:mainfrom
rzikm:rzikm/fix-sslstream-dispose-test

Conversation

@rzikm

@rzikm rzikm commented Sep 1, 2026

Copy link
Copy Markdown
Member

Dispose_ParallelWithHandshake_ThrowsODE can surface the expected disposal race through StreamBuffer.TryWriteToBuffer on Alpine, where the ConnectedStreams frame is absent from the stack trace. This caused the test to fail after #132748 narrowed the exception filter to ConnectedStreams.

Accept the two specific StreamBuffer write methods in addition to ConnectedStreams. Matching the methods rather than the entire type avoids hiding unrelated InvalidOperationException failures from StreamBuffer.

Testing: the targeted outer-loop test passed. The full System.Net.Security functional suite ran 5,369 tests; this test passed, with one unrelated failure in TlsSessionTests.ClientSession_ExternalCertificateValidation_AcceptWithDefaultValidation_FailsOnUntrustedCert on the local Windows environment.

Note

This pull request description was created by GitHub Copilot.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: cfe60e99-25a1-4878-9f47-4dff5e9b1537
Copilot AI lite review requested due to automatic review settings September 1, 2026 14:29
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 4 pipeline(s).
12 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Updates the SslStreamDisposeTest.Dispose_ParallelWithHandshake_ThrowsODE test to treat additional InvalidOperationException stack trace origins as expected during the dispose/handshake race, improving test resilience across platforms/runtimes.

Changes:

  • Expands the exception filter in ValidateExceptionAsync to accept System.IO.StreamBuffer.TryWriteToBuffer and System.IO.StreamBuffer.WriteAsync frames in addition to System.IO.ConnectedStreams.
  • Keeps the filter scoped to specific method names rather than broadly accepting all StreamBuffer failures.
File summaries
File Description
src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamDisposeTest.cs Broadens the expected InvalidOperationException stack-trace filter to cover additional disposal-race call paths.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment on lines +152 to 156
catch (InvalidOperationException ex) when (ex.StackTrace is null ||
ex.StackTrace.Contains("System.IO.ConnectedStreams") ||
ex.StackTrace.Contains("System.IO.StreamBuffer.TryWriteToBuffer") ||
ex.StackTrace.Contains("System.IO.StreamBuffer.WriteAsync"))
{
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants