]> Cypherpunks repositories - gostls13.git/commit
internal/poll: don't use stack-allocated WSAMsg parameters
authorqmuntal <quimmuntal@gmail.com>
Mon, 25 Aug 2025 07:57:49 +0000 (09:57 +0200)
committerQuim Muntal <quimmuntal@gmail.com>
Tue, 26 Aug 2025 10:49:59 +0000 (03:49 -0700)
commitbfd130db02336a174dab781185be369f089373ba
treeeb26cfaace707cc67d7e51823878f176323746c4
parentdae9e456ae6992b3c19a8c5039090ee9ca4d9b7d
internal/poll: don't use stack-allocated WSAMsg parameters

WSAMsg parameters should be passed to Windows as heap pointers instead
of stack pointers. This is because Windows might access the memory
after the syscall returned in case of a non-blocking operation (which
is the common case), and if the WSAMsg is on the stack, the Go
runtime might have moved it around.

Use a sync.Pool to cache WSAMsg structures to avoid a heap allocation
every time a WSAMsg is needed.

Fixes #74933

Cq-Include-Trybots: luci.golang.try:x_net-gotip-windows-amd64
Change-Id: I075e2ceb25cd545224ab3a10d404340faf19fc01
Reviewed-on: https://go-review.googlesource.com/c/go/+/698797
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
src/internal/poll/fd_windows.go