fix(net): return EOF after receive shutdown on Windows #2185

Closed
gunerky wants to merge 1 commit from upstream-pr/2185 into main
gunerky commented 2026-10-09 11:06:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by gunerky on 2026-10-09T11:06:02Z.


What

On Windows, receiving after local shutdown(SHUT_RD) or shutdown(SHUT_RDWR) reports guest EIO when Winsock returns WSAESHUTDOWN. Handle that receive error as a successful zero-byte receive in libkernel recv, recvfrom and recvmsg, and their libSceNet counterparts. Guest errno and data/address/control buffer bytes are preserved. recvfrom returns a zero source length when an address is supplied; recvmsg also clears the control length and returns the accepted input flags, following FreeBSD's EOF path.

Related to #1786, whose description explicitly defers the receive case to a separate PR. This change does not alter either shared native error map or the send functions and does not depend on #1786.

The behavior comes from FreeBSD 11.4 soshutdown and soreceive and kern_recvit / sys_recvmsg. Winsock documents WSAESHUTDOWN after disabling receives. No FreeBSD implementation code was copied. The hardware validation gap and scope limits are recorded in TechnicalDebt.

Tested

Windows x64 (10.0.26300), WinLibs MinGW-w64 GCC 15.2.0 UCRT/POSIX/SEH, Python 3.12.14, Release, BUILD_TESTING=ON, ANYPS5_ENABLE_SPIRV_TOOLS=ON; base d70b89989473ba1f6ae13e44e079e67f1f8a44b0.

  • Six new Windows CTest groups fail on the unmodified receive implementation with errno 5 and pass with the change. They cover 72 shutdown scenarios across TCP, connected UDP and kernel stream/datagram socketpairs, blocking/nonblocking sockets, SHUT_RD/SHUT_RDWR, repeated receives and MSG_PEEK. They also check untouched data/guard/address/control bytes, errno, source/control lengths, message flags and receives without an address.
  • Controls cover normal data, zero-byte UDP datagrams with a source address, SHUT_WR preserving receives, SHUT_RD preserving sends, send errors after SHUT_RDWR, invalid flags/buffers, closed descriptors and would-block errors.
  • Relevant existing socket tests plus the new groups: 11/11 passed. Ten repetitions of each new group: 60/60 passed. Longest new group in the focused run: 0.089 s, with a 20 s timeout.
  • An independent local harness resolves the generated NIDs in the built, patched libc.prx, libkernel.prx and libSceNet.prx and runs the same behavioral cases for all six receive functions: passed. The harness and logs are local artifacts, not repository additions.
  • Full build and libs target: passed. Full CTest with the existing CI 120 s global timeout: 515 passed, 0 failed, 1 skipped (516 registered tests). An earlier run with a 30 s global timeout passed 513/514 and timed out only tls_function_coverage at 30.05 s; its source and registration are unchanged by this patch. This is the existing test addressed separately in #1913. No repository test timeout was increased; all six new groups have a 20 s timeout.
  • Skipped full-suite tests: guest_video_out_wqhd_detection_no_vulkan.
  • Working-tree conventions, test registration and git diff --check: passed.

Linux, PS5 hardware and games: not tested. This is specifically the translation of WSAESHUTDOWN; other host errors and existing behavior for queued data, zero-length stream requests and an already blocked receive are unchanged. These tests do not establish hosted CI timing.

Checklist

  • Based on checked current main; no duplicate receive fix found among open PRs
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw; no silent stubs added
  • No investigation notes, reports, logs or images added to the repository
  • No new third-party code or dependencies
  • Generic behavior, not specific to one title
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4799566781 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2185). Originally posted by [gunerky](https://github.com/gunerky) on 2026-10-09T11:06:02Z. --- ### What On Windows, receiving after local `shutdown(SHUT_RD)` or `shutdown(SHUT_RDWR)` reports guest `EIO` when Winsock returns `WSAESHUTDOWN`. Handle that receive error as a successful zero-byte receive in libkernel `recv`, `recvfrom` and `recvmsg`, and their libSceNet counterparts. Guest errno and data/address/control buffer bytes are preserved. `recvfrom` returns a zero source length when an address is supplied; `recvmsg` also clears the control length and returns the accepted input flags, following FreeBSD's EOF path. Related to #1786, whose description explicitly defers the receive case to a separate PR. This change does not alter either shared native error map or the send functions and does not depend on #1786. The behavior comes from [FreeBSD 11.4 `soshutdown` and `soreceive`](https://github.com/freebsd/freebsd-src/blob/releng/11.4/sys/kern/uipc_socket.c) and [`kern_recvit` / `sys_recvmsg`](https://github.com/freebsd/freebsd-src/blob/releng/11.4/sys/kern/uipc_syscalls.c). [Winsock documents `WSAESHUTDOWN` after disabling receives](https://learn.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-recv). No FreeBSD implementation code was copied. The hardware validation gap and scope limits are recorded in TechnicalDebt. ### Tested Windows x64 (10.0.26300), WinLibs MinGW-w64 GCC 15.2.0 UCRT/POSIX/SEH, Python 3.12.14, Release, `BUILD_TESTING=ON`, `ANYPS5_ENABLE_SPIRV_TOOLS=ON`; base `d70b89989473ba1f6ae13e44e079e67f1f8a44b0`. - Six new Windows CTest groups fail on the unmodified receive implementation with errno 5 and pass with the change. They cover 72 shutdown scenarios across TCP, connected UDP and kernel stream/datagram socketpairs, blocking/nonblocking sockets, `SHUT_RD`/`SHUT_RDWR`, repeated receives and `MSG_PEEK`. They also check untouched data/guard/address/control bytes, errno, source/control lengths, message flags and receives without an address. - Controls cover normal data, zero-byte UDP datagrams with a source address, `SHUT_WR` preserving receives, `SHUT_RD` preserving sends, send errors after `SHUT_RDWR`, invalid flags/buffers, closed descriptors and would-block errors. - Relevant existing socket tests plus the new groups: 11/11 passed. Ten repetitions of each new group: 60/60 passed. Longest new group in the focused run: 0.089 s, with a 20 s timeout. - An independent local harness resolves the generated NIDs in the built, patched `libc.prx`, `libkernel.prx` and `libSceNet.prx` and runs the same behavioral cases for all six receive functions: passed. The harness and logs are local artifacts, not repository additions. - Full build and `libs` target: passed. Full CTest with the existing CI 120 s global timeout: 515 passed, 0 failed, 1 skipped (516 registered tests). An earlier run with a 30 s global timeout passed 513/514 and timed out only `tls_function_coverage` at 30.05 s; its source and registration are unchanged by this patch. This is the existing test addressed separately in #1913. No repository test timeout was increased; all six new groups have a 20 s timeout. - Skipped full-suite tests: `guest_video_out_wqhd_detection_no_vulkan`. - Working-tree conventions, test registration and `git diff --check`: passed. Linux, PS5 hardware and games: not tested. This is specifically the translation of `WSAESHUTDOWN`; other host errors and existing behavior for queued data, zero-length stream requests and an already blocked receive are unchanged. These tests do not establish hosted CI timing. ### Checklist - [x] Based on checked current `main`; no duplicate receive fix found among open PRs - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt - [x] Unimplemented paths throw; no silent stubs added - [x] No investigation notes, reports, logs or images added to the repository - [x] No new third-party code or dependencies - [x] Generic behavior, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-09 14:34:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-09T14:34:02Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#2281 core/libs/prx/libSceNet/CMakeLists.txt L11-12
#2333 docs/dev/TechnicalDebt.md L351
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6083035266 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2185#issuecomment-6083035266). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-09T14:34:02Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #2281 | `core/libs/prx/libSceNet/CMakeLists.txt` [L11-12](https://github.com/boykopovar/AnyPS5/blob/8b393b6e9a8ade9188d4f74a0293e0efd9828597/core/libs/prx/libSceNet/CMakeLists.txt#L11-L12) | | | | #2333 | `docs/dev/TechnicalDebt.md` [L351](https://github.com/boykopovar/AnyPS5/blob/8b393b6e9a8ade9188d4f74a0293e0efd9828597/docs/dev/TechnicalDebt.md#L351) | | |
oneandonlydean commented 2026-10-09 20:09:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T20:09:48Z.


Closing: no title is shown receiving after its own shutdown(SHUT_RD) on Windows, and nothing reaches this path on main. Reopen with the title ID and the log line if one hits the EIO.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6088439204 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2185#issuecomment-6088439204). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-09T20:09:48Z. --- Closing: no title is shown receiving after its own `shutdown(SHUT_RD)` on Windows, and nothing reaches this path on main. Reopen with the title ID and the log line if one hits the `EIO`.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!2185
No description provided.