fix(libkernel): map host socket errors to guest errno #3592

Merged
MarcZX10 merged 3 commits from upstream-pr/3592 into main 2026-10-11 22:11:40 +00:00
MarcZX10 commented 2026-10-11 13:55:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-11T13:55:23Z.


What

Fixes #3573. NativeError() mapped only a small set of POSIX and Winsock errors; all other host errors became guest EIO. This adds a by-name mapping for host socket errors to the corresponding FreeBSD 11 errno values and uses it for both ordinary socket calls and socket-pair creation. Unknown host errors still become EIO, and WSAESHUTDOWN continues to become EPIPE.

This carries Hussein Kadhim's commits a889c98e and c1519d95, preserving their authorship. GuestSocketError tests every table entry on Linux and Windows. TechnicalDebt records host differences that remain unverified against the console.

Tested

  • Linux, GCC 12.2, Release: built libkernel and guest_socket_error_tests.
  • guest_socket_error, guest_udp, guest_socket_read_write, guest_poll, guest_tcp, guest_socket_pair, guest_dup and guest_socket_events — each passed three consecutive runs.
  • python3 tools/check_conventions.py --base upstream/main and git diff --check passed.
  • Windows was not tested locally. Hussein's issue report includes Windows and Linux error-table sweeps and socket scenario comparisons.

Checklist

  • Based on current main; no other open PR implements the same socket-error mapping
  • One topic per PR; follow-ups go in a new pull request
  • 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
  • New third-party code is a submodule built from source
  • Generic behavior, not specific to one title
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4819569825 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3592). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-11T13:55:23Z. --- ### What Fixes #3573. `NativeError()` mapped only a small set of POSIX and Winsock errors; all other host errors became guest `EIO`. This adds a by-name mapping for host socket errors to the corresponding FreeBSD 11 errno values and uses it for both ordinary socket calls and socket-pair creation. Unknown host errors still become `EIO`, and `WSAESHUTDOWN` continues to become `EPIPE`. This carries Hussein Kadhim's commits [`a889c98e`](https://github.com/husseinkad/AnyPS5/commit/a889c98e6a59d62da289f2e6a77355d2b41a1bde) and [`c1519d95`](https://github.com/husseinkad/AnyPS5/commit/c1519d951b2b77346392ccc18204f37c587e7eda), preserving their authorship. `GuestSocketError` tests every table entry on Linux and Windows. TechnicalDebt records host differences that remain unverified against the console. ### Tested - Linux, GCC 12.2, Release: built `libkernel` and `guest_socket_error_tests`. - `guest_socket_error`, `guest_udp`, `guest_socket_read_write`, `guest_poll`, `guest_tcp`, `guest_socket_pair`, `guest_dup` and `guest_socket_events` — each passed three consecutive runs. - `python3 tools/check_conventions.py --base upstream/main` and `git diff --check` passed. - Windows was not tested locally. Hussein's issue report includes Windows and Linux error-table sweeps and socket scenario comparisons. ### Checklist - [x] Based on current `main`; no other open PR implements the same socket-error mapping - [x] One topic per PR; follow-ups go in a new pull request - [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 - [x] New third-party code is a submodule built from source - [x] Generic behavior, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-11 15:28:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-11T15:28:13Z.


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
#3644 docs/dev/TechnicalDebt.md L595
#3649 docs/dev/TechnicalDebt.md L595
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6110595336 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3592#issuecomment-6110595336). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-11T15:28:13Z. --- <!-- 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 | |---|---|---|---| | #3644 | `docs/dev/TechnicalDebt.md` [L595](https://github.com/boykopovar/AnyPS5/blob/31bf997b5342b88ebd4fa8f5629b0ee7400fe176/docs/dev/TechnicalDebt.md#L595) | | | | #3649 | `docs/dev/TechnicalDebt.md` [L595](https://github.com/boykopovar/AnyPS5/blob/31bf997b5342b88ebd4fa8f5629b0ee7400fe176/docs/dev/TechnicalDebt.md#L595) | | |
LeandroLP23 commented 2026-10-11 18:55:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-11T18:55:51Z.


Windows run of this head (a13806581, on main a11c8f7f7): Windows 11 (26300), WinLibs GCC 15.2.0 r7, Release, full build.

  • guest_socket_error, guest_udp, guest_socket_read_write, guest_poll, guest_tcp, guest_socket_pair, guest_dup and guest_socket_events pass 3/3. guest_socket_error runs its _WIN32 table here, so all the WSAE* → FreeBSD cases have now been run on Windows.
  • guest_socket_error checks GuestErrorFromHost directly. With main's Udp.cpp it still passes, so no test checks that NativeError() goes through the table. The other seven pass through it unchanged.
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6112509476 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3592#issuecomment-6112509476). Originally posted by [LeandroLP23](https://github.com/LeandroLP23) on 2026-10-11T18:55:51Z. --- Windows run of this head (`a13806581`, on `main` `a11c8f7f7`): Windows 11 (26300), WinLibs GCC 15.2.0 r7, Release, full build. - `guest_socket_error`, `guest_udp`, `guest_socket_read_write`, `guest_poll`, `guest_tcp`, `guest_socket_pair`, `guest_dup` and `guest_socket_events` pass 3/3. `guest_socket_error` runs its `_WIN32` table here, so all the `WSAE*` → FreeBSD cases have now been run on Windows. - `guest_socket_error` checks `GuestErrorFromHost` directly. With `main`'s `Udp.cpp` it still passes, so no test checks that `NativeError()` goes through the table. The other seven pass through it unchanged.
adriadam10 commented 2026-10-11 21:52:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T21:52:50Z.


Checked the 39 FreeBSD 11 numbers against sys/sys/errno.h, all match. Thanks @LeandroLP23 for the Windows run: it showed that guest_socket_error only covers the table, not that NativeError() goes through it.

Added one commit on your branch, rebased on current main:

  • GuestUdp.cpp: sending on an unconnected UDP socket must report guest EDESTADDRREQ (39) (Linux only). Setting that table entry back to EIO makes guest_udp abort; with the fix it passes.

guest_socket_error, guest_udp, guest_tcp, guest_poll, guest_socket_pair, guest_dup, guest_socket_events and guest_socket_read_write pass on Linux; merging once CI is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6114208319 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3592#issuecomment-6114208319). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-11T21:52:50Z. --- Checked the 39 FreeBSD 11 numbers against `sys/sys/errno.h`, all match. Thanks @LeandroLP23 for the Windows run: it showed that `guest_socket_error` only covers the table, not that `NativeError()` goes through it. Added one commit on your branch, rebased on current `main`: - `GuestUdp.cpp`: sending on an unconnected UDP socket must report guest `EDESTADDRREQ` (39) (Linux only). Setting that table entry back to `EIO` makes `guest_udp` abort; with the fix it passes. `guest_socket_error`, `guest_udp`, `guest_tcp`, `guest_poll`, `guest_socket_pair`, `guest_dup`, `guest_socket_events` and `guest_socket_read_write` pass on Linux; merging once CI is green.
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!3592
No description provided.