fix(libkernel): report EPIPE for a stream send on a connection the peer closed on Windows #8670

Merged
xXPBSXx merged 1 commit from upstream-pr/8670 into main 2026-10-22 17:40:04 +00:00
xXPBSXx commented 2026-10-20 20:36:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-20T20:36:51Z.


What

sosend_generic (uipc_socket.c#L1260-L1264) fails a send on a socket that can send no more with EPIPE before it looks at so_error. Winsock reports the same send as WSAECONNABORTED or WSAECONNRESET, which send, sendto and write passed on as ECONNABORTED or ECONNRESET. SendError now maps both to EPIPE for a stream socket. The send-after-close checks of guest_tcp, guest_socket_read_write and guest_socket_pair, which only ran on Linux, now run on Windows too (the pair test sends until the first failure, because the first send after the peer's close still succeeds on the loopback connection; the Technical debt entry says so).
Fixes #8669
Overlap: git merge-tree has one conflict each with #8483 (both edit the socketpair entry in docs/dev/debt/libkernel.md) and #7850 (open); the other open socket PRs (#8499, #8492, #8474, #8463, #8448, #7090, #7511, #7490) are clean. Whichever lands second rebases. pr_overlap was not run.

Tested

Windows 10 (19045), MinGW-w64 GCC 15.2.0, Release, on current upstream/main + this commit:

  • guest_socket_read_write and guest_socket_pair fail without the change to Udp.cpp (exit 0xc0000409) and pass with it; guest_tcp passes either way.
  • guest_sce_net, guest_socket_error, guest_udp, guest_poll and guest_recvmsg_memory pass.
  • python tools/check_conventions.py --base upstream/main: 0 errors, 1 warning (debt-length, the edited socketpair entry was already over 1000 characters).
  • Not tested: Linux/macOS (the changed lines are Windows-only; the test edits only widen what runs), a console.

Checklist

  • Based on current main; no other open PR implements the same functions
  • 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 notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source (none added)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: #8669
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

AI-assisted (Claude Code).

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4942151298 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8670). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-20T20:36:51Z. --- ### What `sosend_generic` ([uipc_socket.c#L1260-L1264](https://github.com/freebsd/freebsd-src/blob/release/11.4.0/sys/kern/uipc_socket.c#L1260-L1264)) fails a send on a socket that can send no more with `EPIPE` before it looks at `so_error`. Winsock reports the same send as `WSAECONNABORTED` or `WSAECONNRESET`, which `send`, `sendto` and `write` passed on as `ECONNABORTED` or `ECONNRESET`. `SendError` now maps both to `EPIPE` for a stream socket. The send-after-close checks of `guest_tcp`, `guest_socket_read_write` and `guest_socket_pair`, which only ran on Linux, now run on Windows too (the pair test sends until the first failure, because the first send after the peer's close still succeeds on the loopback connection; the Technical debt entry says so). Fixes #8669 Overlap: `git merge-tree` has one conflict each with #8483 (both edit the socketpair entry in `docs/dev/debt/libkernel.md`) and #7850 (open); the other open socket PRs (#8499, #8492, #8474, #8463, #8448, #7090, #7511, #7490) are clean. Whichever lands second rebases. `pr_overlap` was not run. ### Tested Windows 10 (19045), MinGW-w64 GCC 15.2.0, Release, on current upstream/main + this commit: - `guest_socket_read_write` and `guest_socket_pair` fail without the change to `Udp.cpp` (exit 0xc0000409) and pass with it; `guest_tcp` passes either way. - `guest_sce_net`, `guest_socket_error`, `guest_udp`, `guest_poll` and `guest_recvmsg_memory` pass. - `python tools/check_conventions.py --base upstream/main`: 0 errors, 1 warning (`debt-length`, the edited socketpair entry was already over 1000 characters). - Not tested: Linux/macOS (the changed lines are Windows-only; the test edits only widen what runs), a console. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [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 notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source (none added) - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: #8669 - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes AI-assisted (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MarcZX10 commented 2026-10-20 20:41:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-20T20:41:58Z.

Review: APPROVED


Reviewed the Windows-specific mapping and regressions. SendError applies the WSAECONNABORTED/WSAECONNRESET to EPIPE translation only for guest stream sockets; the existing datagram and WSAENOTCONN paths are unchanged. The socket, read/write and socket-pair tests now exercise the close/send behavior on Windows, including the documented first-send success on the loopback pair. The author reports a Windows negative control and passing focused socket tests; hosted Windows CI is skipped, so I am relying on that reported platform run rather than claiming independent Windows validation. I found no blocking issue in the diff.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5591453696 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8670#pullrequestreview-5591453696). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-20T20:41:58Z. **Review:** APPROVED --- Reviewed the Windows-specific mapping and regressions. `SendError` applies the `WSAECONNABORTED`/`WSAECONNRESET` to `EPIPE` translation only for guest stream sockets; the existing datagram and `WSAENOTCONN` paths are unchanged. The socket, read/write and socket-pair tests now exercise the close/send behavior on Windows, including the documented first-send success on the loopback pair. The author reports a Windows negative control and passing focused socket tests; hosted Windows CI is skipped, so I am relying on that reported platform run rather than claiming independent Windows validation. I found no blocking issue in the diff.
cadenasynyster commented 2026-10-20 22:00:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by cadenasynyster on 2026-10-20T22:00:35Z.


Independent Windows run of this PR. The review notes that hosted Windows CI is skipped, so this adds a second host.

Environment: Windows 11 10.0.26300, Ryzen 7 9800X3D, WinLibs GCC 15.2.0 r7 UCRT, Release, BUILD_TESTING=ON. I built only the three affected test targets.

Results:

  • PR head: guest_socket_read_write, guest_tcp and guest_socket_pair all pass.
  • Baseline: I kept the PR's tests and replaced only core/libs/prx/libkernel/Socket/src/Udp.cpp with its base version, then rebuilt. guest_socket_read_write and guest_socket_pair fail with exit 0xc0000409, and guest_tcp passes. This matches the description. I restored the PR's Udp.cpp afterwards.

Not run: other platforms, the other socket tests listed in the description, the full repository CTest, and any title or console run.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6302680133 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8670#issuecomment-6302680133). Originally posted by [cadenasynyster](https://github.com/cadenasynyster) on 2026-10-20T22:00:35Z. --- Independent Windows run of this PR. The review notes that hosted Windows CI is skipped, so this adds a second host. **Environment:** Windows 11 10.0.26300, Ryzen 7 9800X3D, WinLibs GCC 15.2.0 r7 UCRT, Release, BUILD_TESTING=ON. I built only the three affected test targets. **Results:** - PR head: `guest_socket_read_write`, `guest_tcp` and `guest_socket_pair` all pass. - Baseline: I kept the PR's tests and replaced only `core/libs/prx/libkernel/Socket/src/Udp.cpp` with its base version, then rebuilt. `guest_socket_read_write` and `guest_socket_pair` fail with exit 0xc0000409, and `guest_tcp` passes. This matches the description. I restored the PR's `Udp.cpp` afterwards. **Not run:** other platforms, the other socket tests listed in the description, the full repository CTest, and any title or console run. AI-assisted: yes
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!8670
No description provided.