diff options
| author | qmuntal <quimmuntal@gmail.com> | 2025-09-12 10:13:15 +0200 |
|---|---|---|
| committer | Quim Muntal <quimmuntal@gmail.com> | 2025-09-12 07:12:50 -0700 |
| commit | a4e25c3d657cf7c3f3a921cc99ea60ad5a337b82 (patch) | |
| tree | 7e6cd23a75579c6bcdd8eb476c5598ec3c95e2e1 | |
| parent | dd8276657f2244193d399f01941ee1d76a79529d (diff) | |
| download | go-a4e25c3d657cf7c3f3a921cc99ea60ad5a337b82.tar.xz | |
net,internal/poll: skip TestAllocs when race is enabled on Windows
The Windows implementation of several network protocols make use of
sync.Pool, which randomly drops cached items when race is enabled.
While here, zero out the control buffer to allow it to be garbage
collected.
Fixes #75341
Change-Id: Ie20e21adef2edc02ca7b4a78012dd5f3a9f03bee
Reviewed-on: https://go-review.googlesource.com/c/go/+/703195
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
| -rw-r--r-- | src/internal/poll/fd_windows.go | 2 | ||||
| -rw-r--r-- | src/net/udpsock_test.go | 7 |
2 files changed, 9 insertions, 0 deletions
diff --git a/src/internal/poll/fd_windows.go b/src/internal/poll/fd_windows.go index f8d41bafd1..23500d3e39 100644 --- a/src/internal/poll/fd_windows.go +++ b/src/internal/poll/fd_windows.go @@ -196,6 +196,8 @@ func freeWSAMsg(msg *windows.WSAMsg) { // Clear pointers to buffers so they can be released by garbage collector. msg.Buffers.Len = 0 msg.Buffers.Buf = nil + msg.Control.Len = 0 + msg.Control.Buf = nil wsaMsgPool.Put(msg) } diff --git a/src/net/udpsock_test.go b/src/net/udpsock_test.go index 7b4bf328e2..a79e9f83c1 100644 --- a/src/net/udpsock_test.go +++ b/src/net/udpsock_test.go @@ -8,6 +8,7 @@ import ( "errors" "fmt" "internal/asan" + "internal/race" "internal/testenv" "net/netip" "os" @@ -491,6 +492,12 @@ func TestAllocs(t *testing.T) { case "plan9", "js", "wasip1": // These implementations have not been optimized. t.Skipf("skipping on %v", runtime.GOOS) + case "windows": + if race.Enabled { + // The Windows implementation make use of sync.Pool, + // which randomly drops cached items when race is enabled. + t.Skip("skipping test in race") + } } if !testableNetwork("udp4") { t.Skipf("skipping: udp4 not available") |
