Skip to content

[main] Forward-port SocketAsyncEventArgs address-family reuse fix - #10450

Merged
rbhanda merged 3 commits into
mainfrom
users/rbhanda/oob-20261025-sockets-main
Oct 27, 2026
Merged

rbhanda merged 3 commits into
mainfrom
users/rbhanda/oob-20261025-sockets-main

Conversation

@rbhanda

@rbhanda rbhanda commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Forward-port the released .NET 11 RC3 SocketAsyncEventArgs fix to main.

  • Size the Windows native socket-address buffer from the current socket's address family, grow it when reused, and use the allocated buffer length for WSAMsg.
  • Replace a cached managed SocketAddress when it is too small for the current socket.
  • Preserve the regression tests for event-args reuse across IPv4/IPv6 and caller-supplied SocketAddress family mismatches.

Source

Clean forward-port of public commit 6f0fa48bddc8e7baaf5932d9340487ef12621103, included in public tag v11.0.0-rc.3.26522.148. No servicing version changes or unrelated fixes are included.

@wfurt, please review the forward-port and confirm the fix and regression coverage on main.

Validation

  • git diff --check passed.
  • The stable patch ID matches the published source commit; the three-file change applied without conflicts.
  • Attempted the targeted System.Net.Sockets build locally. It stopped at SDK resolution: this checkout requires .NET SDK 11.0.100-rc.1.26420.103, which is not installed. The changed product and regression tests have not been built or executed locally.
  • Windows build/test CI and owner approval are still required. This PR is intentionally a draft.

Note

This PR was prepared with GitHub Copilot.

(cherry picked from commit 6f0fa48)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 6d2559fe-05fb-4a93-9b04-40c9ac80fbd5
@rbhanda
rbhanda requested a review from wfurt October 25, 2026 21:40
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
1 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
dotnet-policy-service Bot requested a review from a team October 25, 2026 21:41
@rbhanda
rbhanda marked this pull request as ready for review October 26, 2026 15:40
Copilot AI balanced review requested due to automatic review settings October 26, 2026 15:40
@rbhanda
rbhanda enabled auto-merge October 26, 2026 15:44

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

Native buffer growth frees the old allocation before its replacement succeeds, allowing a double-free if allocation fails.

1 open issue
What changed in this PR

Forward-ports the SocketAsyncEventArgs address-family reuse fix to main, updating socket-address buffer sizing and adding regression coverage in System.Net.Sockets.

Changes:

  • Size Windows native buffers from the current socket’s address family, grow them as needed, and use the declared buffer length for WSAMsg.
  • Replace cached managed socket-address buffers when too small.
  • Add regression tests for IPv4/IPv6 event-args reuse and caller-supplied address-family mismatches.
File Description
src/​runtime/​src/​libraries/​System.Net.Sockets/​tests/​FunctionalTests/​ReceiveFrom.cs Adds cross-family reuse and family-mismatch regression tests.
src/​runtime/​src/​libraries/​System.Net.Sockets/​src/​System/​Net/​Sockets/​SocketAsyncEventArgs.Windows.cs Tracks native buffer capacity and adjusts allocation and WSAMsg sizing.
src/​runtime/​src/​libraries/​System.Net.Sockets/​src/​System/​Net/​Sockets/​Socket.cs Replaces undersized cached managed socket-address buffers.

Review effort: Balanced

@rbhanda
rbhanda merged commit d52b2ac into main Oct 27, 2026
11 checks passed
@rbhanda
rbhanda deleted the users/rbhanda/oob-20261025-sockets-main branch October 27, 2026 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants