fix(libSceNet): failures also set libkernel's errno #4112

Merged
jdmagic merged 1 commit from upstream-pr/4112 into main 2026-10-12 07:25:24 +00:00
jdmagic commented 2026-10-11 23:29:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jdmagic on 2026-10-11T23:29:58Z.


What

libSceNet stored the errno of a failed call only in its own slot (sceNetErrnoLoc). Titles that use the BSD socket model read errno after a libSceNet call instead; shadPS4 mirrors its net errno into the kernel errno the same way (SetKernelErrnoHook). Failures now set both: libSceNet's slot and libkernel's __error().

Sackboy: A Big Adventure (PPSA01289) reads errno through Unreal's GetLastErrorCode after sceNetRecvfrom. It never saw EWOULDBLOCK, so UIpNetDriver::TickDispatch kept receiving and the game thread never left its first networked frame.

  • guest_sce_net: after sceNetSocketClose on a closed socket, __error() holds EBADF as well as sceNetErrnoLoc().

Tested

Windows 11, MinGW-w64 GCC 15.2.0 (WinLibs r7), on main bca7a29d.

  • guest_sce_net, guest_socket_events, guest_socket_pair, guest_socket_read_write, guest_kernel_errors, guest_filesystem, guest_file_vector: 7/7 passed. The full ctest was not run on this branch.
  • The new guest_sce_net check fails on main without the change to Export.cpp.
  • PPSA01289 (own dump, converted with the relinker): TickDispatch returns once the socket is drained and the game thread moves on. With the other libSceNet fixes (the epoll and close/setsockopt PRs) the title reaches its first-boot gamma screen; getting there also needs changes outside this PR.

This PR and the two other libSceNet PRs from this branch set are independent and merge cleanly with each other.

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

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4823207316 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4112). Originally posted by [jdmagic](https://github.com/jdmagic) on 2026-10-11T23:29:58Z. --- ### What libSceNet stored the errno of a failed call only in its own slot (`sceNetErrnoLoc`). Titles that use the BSD socket model read `errno` after a libSceNet call instead; shadPS4 mirrors its net errno into the kernel errno the same way (`SetKernelErrnoHook`). Failures now set both: libSceNet's slot and libkernel's `__error()`. Sackboy: A Big Adventure (PPSA01289) reads `errno` through Unreal's `GetLastErrorCode` after `sceNetRecvfrom`. It never saw `EWOULDBLOCK`, so `UIpNetDriver::TickDispatch` kept receiving and the game thread never left its first networked frame. - `guest_sce_net`: after `sceNetSocketClose` on a closed socket, `__error()` holds `EBADF` as well as `sceNetErrnoLoc()`. ### Tested Windows 11, MinGW-w64 GCC 15.2.0 (WinLibs r7), on main bca7a29d. - `guest_sce_net`, `guest_socket_events`, `guest_socket_pair`, `guest_socket_read_write`, `guest_kernel_errors`, `guest_filesystem`, `guest_file_vector`: 7/7 passed. The full `ctest` was not run on this branch. - The new `guest_sce_net` check fails on main without the change to `Export.cpp`. - PPSA01289 (own dump, converted with the relinker): `TickDispatch` returns once the socket is drained and the game thread moves on. With the other libSceNet fixes (the epoll and close/setsockopt PRs) the title reaches its first-boot gamma screen; getting there also needs changes outside this PR. This PR and the two other libSceNet PRs from this branch set are independent and merge cleanly with each other. ### 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](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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!4112
No description provided.