Skip to content

patch: internal/poll: move rsan to heap on windows #158

@nickkhyl

Description

@nickkhyl

I'd like to cherry-pick the changes from https://go-review.googlesource.com/c/go/+/753040 into our Go tree before they land upstream to fix tailscale/tailscale#18884 (golang#77975).

internal/poll: move rsan to heap on windows

According to https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsarecvfrom,
the memory pointed to by lpFromlen must remain available during the
overlapped I/O, and therefore cannot be allocated on the stack.

[CL 685417](https://go.dev/cl/685417) moved the rsan field out of the operation struct and placed
it on stack, which violates the above requirement and causes stack
corruption.

Unfortunately, it is no longer possible to cleanly revert [CL 685417](https://go.dev/cl/685417).
Instead of attempting to revert it, this CL bundles rsan together
with rsa in the same sync.Pool. The new wsaRsa struct is still in the
same size class, so no additional overhead is introduced by this
change.

/cc @tailscale/tooling

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions