fix(net): report EPIPE for a send after shutdown on Windows #1786

Merged
Zurisen merged 1 commit from upstream-pr/1786 into main 2026-10-10 04:41:19 +00:00
Zurisen commented 2026-10-08 19:10:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Zurisen on 2026-10-08T19:10:04Z.


What

Fixes #1785. Both Windows error maps, libkernel NativeError and libSceNet native_error, translate WSAESHUTDOWN to 32 (EPIPE), as FreeBSD send(2) reports and as the Linux maps already do for the host's EPIPE. A send, sendto or sendmsg on a socket shut down for writing now fails with EPIPE instead of EIO.

Winsock also returns WSAESHUTDOWN from recv after shutdown(SD_RECEIVE), where FreeBSD returns 0. That case reported EIO before and reports EPIPE now; returning 0 there is a change to the receive paths and is left for a separate pull request.

Tested

Windows 11 (10.0.26200), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, RTX 4070 Laptop:

  • guest_tcp: after the loopback exchange, shutdown_nid_postfix(client, 1) and send_nid_postfix(client, ...) fails with errno 32.
  • guest_sce_net: sceNetShutdown(accepted, 1) and sceNetSend(accepted, ...) fails with 0x80410120 and errno 32. It runs on the accepted socket so that the client's later sends still fail through the reset from #2295, not through EPIPE.
  • Both tests fail on main and pass with the change.
  • Full ctest with ANYPS5_REQUIRE_VULKAN=1 --repeat until-fail:3: 557/559 passed on a291ae0f. Both failures also fail on main locally: pr_overlap_encoding patches subprocess._text_encoding, which Python 3.10 does not have, and patched_libraries cannot load libSceVideoOut.prx, whose NID patching fails on main (#2462).
  • Linux: not run locally; the Linux maps already return 32 for the host's EPIPE, and the sends use MSG_NOSIGNAL as the existing cases do.

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 (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4791587338 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1786). Originally posted by [Zurisen](https://github.com/Zurisen) on 2026-10-08T19:10:04Z. --- ### What Fixes #1785. Both Windows error maps, libkernel `NativeError` and libSceNet `native_error`, translate `WSAESHUTDOWN` to 32 (`EPIPE`), as FreeBSD `send(2)` reports and as the Linux maps already do for the host's `EPIPE`. A send, sendto or sendmsg on a socket shut down for writing now fails with `EPIPE` instead of `EIO`. Winsock also returns `WSAESHUTDOWN` from `recv` after `shutdown(SD_RECEIVE)`, where FreeBSD returns 0. That case reported `EIO` before and reports `EPIPE` now; returning 0 there is a change to the receive paths and is left for a separate pull request. ### Tested Windows 11 (10.0.26200), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, RTX 4070 Laptop: - `guest_tcp`: after the loopback exchange, `shutdown_nid_postfix(client, 1)` and `send_nid_postfix(client, ...)` fails with errno 32. - `guest_sce_net`: `sceNetShutdown(accepted, 1)` and `sceNetSend(accepted, ...)` fails with `0x80410120` and errno 32. It runs on the accepted socket so that the client's later sends still fail through the reset from #2295, not through `EPIPE`. - Both tests fail on main and pass with the change. - Full `ctest` with `ANYPS5_REQUIRE_VULKAN=1 --repeat until-fail:3`: 557/559 passed on `a291ae0f`. Both failures also fail on main locally: `pr_overlap_encoding` patches `subprocess._text_encoding`, which Python 3.10 does not have, and `patched_libraries` cannot load `libSceVideoOut.prx`, whose NID patching fails on main (#2462). - Linux: not run locally; the Linux maps already return 32 for the host's `EPIPE`, and the sends use `MSG_NOSIGNAL` as the existing cases do. ### 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 (`NotImplemented_nid_no_patch`); silent stubs are listed in TechnicalDebt - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes
MarcZX10 commented 2026-10-08 21:33:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-08T21:33:38Z.


Update after checking the latest state: Build (Linux and Windows), Conventions, and Progress report have all passed on this head. The overlap warning for #2001 no longer applies; a collaborator closed that broad cleanup PR.\n\nOne contribution-rule follow-up remains: this PR base is b858fdc48e29c3ab7476782199d8a41999d46d59, while current upstream main is 6cc0503dacc9d9697d23001d4103780ad2e9acba. Please rebase onto current main and rerun checks on the updated head before merge.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6069477551 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1786#issuecomment-6069477551). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-08T21:33:38Z. --- Update after checking the latest state: Build (Linux and Windows), Conventions, and Progress report have all passed on this head. The overlap warning for #2001 no longer applies; a collaborator closed that broad cleanup PR.\n\nOne contribution-rule follow-up remains: this PR base is `b858fdc48e29c3ab7476782199d8a41999d46d59`, while current upstream `main` is `6cc0503dacc9d9697d23001d4103780ad2e9acba`. Please rebase onto current `main` and rerun checks on the updated head before merge.
MarcZX10 commented 2026-10-09 09:14:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T09:14:58Z.


Update to my earlier contribution-rule note: upstream main has since advanced to d9484c719b2a5ac6201e27f8657e0fb0f01e648c, while this PR remains based on b858fdc48e29c3ab7476782199d8a41999d46d59. The Linux, Windows, Conventions and Progress checks on the current head pass, but please rebase onto current main and rerun them before merge. The merged #2113 policy means the full Build results here were collaborator-triggered; after a rebase, request another full run from a collaborator if needed.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6078010257 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1786#issuecomment-6078010257). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-09T09:14:58Z. --- Update to my earlier contribution-rule note: upstream `main` has since advanced to `d9484c719b2a5ac6201e27f8657e0fb0f01e648c`, while this PR remains based on `b858fdc48e29c3ab7476782199d8a41999d46d59`. The Linux, Windows, Conventions and Progress checks on the current head pass, but please rebase onto current `main` and rerun them before merge. The merged #2113 policy means the full Build results here were collaborator-triggered; after a rebase, request another full run from a collaborator if needed.
Zurisen commented 2026-10-09 16:22:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Zurisen on 2026-10-09T16:22:19Z.


Rebased onto d70b8998; 506/507 pass locally on Windows (pr_overlap_encoding also fails on main with Python 3.10). The new head needs a full Build run.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6084871114 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1786#issuecomment-6084871114). Originally posted by [Zurisen](https://github.com/Zurisen) on 2026-10-09T16:22:19Z. --- Rebased onto `d70b8998`; 506/507 pass locally on Windows (`pr_overlap_encoding` also fails on main with Python 3.10). The new head needs a full Build run.
Zurisen commented 2026-10-10 00:10:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Zurisen on 2026-10-10T00:10:08Z.


Rebased onto a291ae0f to resolve the conflict with #2295 in GuestSceNet.cpp. #2295 sends unread data to the accepted socket so that closing it resets the connection and the client's later sends fail at once. A shutdown on the client would make those sends fail with EPIPE instead, so the shutdown check now runs on the accepted socket: sceNetShutdown(accepted, 1), then sceNetSend(accepted, ...) fails with errno 32. Without the libSceNet change that check fails; with it, guest_sce_net and guest_tcp pass.

Full suite locally on Windows: 557/559. The two failures also fail on main here: pr_overlap_encoding (Python 3.10) and patched_libraries, which cannot load libSceVideoOut.prx because of #2462.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6091433574 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1786#issuecomment-6091433574). Originally posted by [Zurisen](https://github.com/Zurisen) on 2026-10-10T00:10:08Z. --- Rebased onto `a291ae0f` to resolve the conflict with #2295 in `GuestSceNet.cpp`. #2295 sends unread data to the accepted socket so that closing it resets the connection and the client's later sends fail at once. A shutdown on the client would make those sends fail with `EPIPE` instead, so the shutdown check now runs on the accepted socket: `sceNetShutdown(accepted, 1)`, then `sceNetSend(accepted, ...)` fails with errno 32. Without the libSceNet change that check fails; with it, `guest_sce_net` and `guest_tcp` pass. Full suite locally on Windows: 557/559. The two failures also fail on main here: `pr_overlap_encoding` (Python 3.10) and `patched_libraries`, which cannot load `libSceVideoOut.prx` because of #2462.
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!1786
No description provided.