Skip to content

Retry peer-reset timeouts in socket disposal tests on BSD/Apple - #133371

Merged
MihaZupan merged 2 commits into
dotnet:mainfrom
MihaZupan:fix-131990
Sep 8, 2026
Merged

MihaZupan merged 2 commits into
dotnet:mainfrom
MihaZupan:fix-131990

Conversation

@MihaZupan

Copy link
Copy Markdown
Member

Fixes #131990.

TcpReceiveSendGetsCanceledByDispose can time out waiting for the peer
to observe a reset after local cancellation has succeeded. This is
consistent with the documented BSD TCP reset-validation issue:
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=296594

The existing retry loop handles assertion failures, but not
TimeoutException. Convert only peer-receive timeouts on Apple/FreeBSD
send paths into logged assertion failures, allowing the existing
eight-attempt loop to retry with fresh sockets.

This preserves the peer-reset assertion. Timeouts waiting for local
cancellation or disposal still fail immediately. Also ensure the sending
socket is disposed on exceptional exits.

Validation

  • Linux functional suite: 2,418 passed, 24 skipped, zero failures.
  • Linux inline-completion test: passed.
  • Helix macOS 27 ARM64: 174 iterations, 18,792 cases passed, zero skips.
    Iteration 174 encountered a peer-reset timeout in SendReceive_Apm;
    the same test then passed after retry, exercising the recovery path.

Helix results and captured retry

Note

This change and description were prepared with GitHub Copilot.

@MihaZupan MihaZupan added this to the 12.0.0 milestone Sep 7, 2026
@MihaZupan MihaZupan self-assigned this Sep 7, 2026
Copilot AI lite review requested due to automatic review settings September 7, 2026 17:38
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
13 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: @karelz, @dotnet/ncl
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.

🟢 Approval recommended

The change is test-only, narrowly scoped, and the retry behavior is constrained to the flaky peer-reset observation case on specific platforms.

Pull request overview

This PR makes the TcpReceiveSendGetsCanceledByDispose functional test more resilient on Apple/FreeBSD by allowing an existing retry loop to also retry peer-side reset observation timeouts (while keeping local cancellation/disposal timeouts as immediate failures), and ensures socket1 is disposed even on exceptional exits.

Changes:

  • Wrap socket1 in a using to guarantee cleanup on all exits from the retry body.
  • On Apple/FreeBSD send path, convert peer-receive TimeoutException into an assertion failure so RetryHelper can retry with fresh sockets.
File summaries
File Description
src/libraries/System.Net.Sockets/tests/FunctionalTests/SendReceive/SendReceive.cs Updates the retry/cleanup behavior in TcpReceiveSendGetsCanceledByDispose to handle peer-reset timeouts on Apple/FreeBSD and ensure socket1 disposal.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread src/libraries/System.Net.Sockets/tests/FunctionalTests/SendReceive/SendReceive.cs Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings September 7, 2026 17:47

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.

🟢 Approval recommended

The change is narrowly scoped to test resilience with platform guards, preserves the core assertion, and improves resource cleanup without altering product code.

Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@MihaZupan
MihaZupan enabled auto-merge (squash) September 8, 2026 08:04
@MihaZupan
MihaZupan disabled auto-merge September 8, 2026 08:04
@MihaZupan
MihaZupan enabled auto-merge (squash) September 8, 2026 08:07
@MihaZupan

Copy link
Copy Markdown
Member Author

/ba-g Quic failure is unrelated

@MihaZupan
MihaZupan merged commit 9eaee61 into dotnet:main Sep 8, 2026
79 of 81 checks passed
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.

TcpReceiveSendGetsCanceledByDispose timed out

3 participants