]> Cypherpunks repositories - gostls13.git/commitdiff
net,internal/poll: skip TestAllocs when race is enabled on Windows
authorqmuntal <quimmuntal@gmail.com>
Fri, 12 Sep 2025 08:13:15 +0000 (10:13 +0200)
committerQuim Muntal <quimmuntal@gmail.com>
Fri, 12 Sep 2025 14:12:50 +0000 (07:12 -0700)
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>
src/internal/poll/fd_windows.go
src/net/udpsock_test.go

index f8d41bafd13a69f41073e0a431e2894302e7aff5..23500d3e390f4aa601227495e628d93c5dbec7f7 100644 (file)
@@ -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)
 }
 
index 7b4bf328e28f9bc4b71ae0163902bc2269efaeec..a79e9f83c11098249d52699d9076fb899e9b1ae3 100644 (file)
@@ -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")