fix(libc): map ENODATA, ENOSR, ENOSTR, EOTHER, and ETIME in GuestErrnoFromHost #27924

Open
gurtgg wants to merge 1 commit from upstream-pr/27924 into main
gurtgg commented 2026-11-27 20:32:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by gurtgg on 2026-11-27T20:32:04Z.


What

  • Map #ifdef-guarded ENODATA (1040), ENOSR (1050), ENOSTR (1051), EOTHER (1062), and ETIME (1074) in HostErrnoMap[] inside GuestErrnoFromHost_nid_no_patch (core/libs/prx/libc/src/HostErrno.cpp), matching the extended guest error codes defined in core/libs/prx/libc/src/Errors.cpp (with 1040, 1050, 1051, and 1074 also matching SceV2SyserrorMessage in core/libs/prx/libc/src/exception/StandardExceptions.cpp, which does not define 1062), while keeping ENOTRECOVERABLE (95) and EOWNERDEAD (96) unchanged.
  • Prevents GuestErrnoFromHost_nid_no_patch (called across FileAndHeap.cpp, StandardStreams.cpp, AllocatingStrings.cpp, FormattingWide.cpp, libSceLibcInternal/Spawn.cpp, libScePosixForWebKit/Resolver.cpp, and libkernel/Time/Time.cpp) from falling through error > 0 && error <= 34 and returning GuestEio (5) for those host errnos on Windows UCRT, Linux, and macOS.

Tested

  • guest_atoi (core/libs/tests/GuestAtoi.cpp, errnoCases[]): verifies #ifdef-guarded ENODATA -> 1040, ENOSR -> 1050, ENOSTR -> 1051, EOTHER -> 1062, and ETIME -> 1074 (negative control returning 5 on unmodified main) alongside existing mapped errnos, ENOENT/ERANGE, and 0/-1/9999 fallback to 5.

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 and upstream licence notices (tools/check_conventions.py passes)
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Negative-control regression test (plus valid/boundary cases) fails against unmodified main and passes after fix
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

Summary by CodeRabbit

  • Bug Fixes
    • Improved compatibility when handling additional system error conditions, including missing data, unavailable streams, and timeouts.
    • Error values are now recognized where supported by the host platform.
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5532732758 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/27924). Originally posted by [gurtgg](https://github.com/gurtgg) on 2026-11-27T20:32:04Z. --- ### What - Map `#ifdef`-guarded `ENODATA` (`1040`), `ENOSR` (`1050`), `ENOSTR` (`1051`), `EOTHER` (`1062`), and `ETIME` (`1074`) in `HostErrnoMap[]` inside `GuestErrnoFromHost_nid_no_patch` (`core/libs/prx/libc/src/HostErrno.cpp`), matching the extended guest error codes defined in `core/libs/prx/libc/src/Errors.cpp` (with `1040`, `1050`, `1051`, and `1074` also matching `SceV2SyserrorMessage` in `core/libs/prx/libc/src/exception/StandardExceptions.cpp`, which does not define `1062`), while keeping `ENOTRECOVERABLE` (`95`) and `EOWNERDEAD` (`96`) unchanged. - Prevents `GuestErrnoFromHost_nid_no_patch` (called across `FileAndHeap.cpp`, `StandardStreams.cpp`, `AllocatingStrings.cpp`, `FormattingWide.cpp`, `libSceLibcInternal/Spawn.cpp`, `libScePosixForWebKit/Resolver.cpp`, and `libkernel/Time/Time.cpp`) from falling through `error > 0 && error <= 34` and returning `GuestEio` (`5`) for those host errnos on Windows UCRT, Linux, and macOS. ### Tested - `guest_atoi` (`core/libs/tests/GuestAtoi.cpp`, `errnoCases[]`): verifies `#ifdef`-guarded `ENODATA -> 1040`, `ENOSR -> 1050`, `ENOSTR -> 1051`, `EOTHER -> 1062`, and `ETIME -> 1074` (negative control returning `5` on unmodified `main`) alongside existing mapped errnos, `ENOENT`/`ERANGE`, and `0`/`-1`/`9999` fallback to `5`. ### 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 and upstream licence notices (`tools/check_conventions.py` passes) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's technical debt file - [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 behaviour, not specific to one title - [x] Negative-control regression test (plus valid/boundary cases) fails against unmodified `main` and passes after fix - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Bug Fixes** * Improved compatibility when handling additional system error conditions, including missing data, unavailable streams, and timeouts. * Error values are now recognized where supported by the host platform. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
PrivacyOnion commented 2026-11-27 20:35:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-27T20:35:24Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 9ecd67a22e:

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_atoi_tests built cleanly.
  • CTest (guest_atoi):
    1/1 Test #1482: guest_atoi .......................   Passed    0.01 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libc/src/HostErrno.cpp reverted to main and the new tests kept, the suite fails:
    1/1 Test #1482: guest_atoi .......................***Failed    0.03 sec
    0% tests passed, 1 tests failed out of 1
    
    Restoring the change makes it pass again.
  • Code reading:
    • Verified HostErrnoMap mappings in core/libs/prx/libc/src/HostErrno.cpp: ENODATA -> 1040, ENOSR -> 1050, ENOSTR -> 1051, EOTHER -> 1062, ETIME -> 1074 match the guest error codes defined in Errors.cpp.
    • Verified GuestErrnoFromHost_nid_no_patch linear search properly looks up the host errno and returns the mapped guest errno before the fallback bounds check error > 0 && error <= 34.
    • Verified all macros ENODATA, ENOSR, ENOSTR, EOTHER, and ETIME are cleanly wrapped with #ifdef guards for portability across Linux, Windows UCRT, and macOS.
    • Verified unit test core/libs/tests/GuestAtoi.cpp errnoCases[] adds valid regression cases exercising each newly mapped host error code against its expected guest integer value.
    • Verified compliance with AGENTS.md rules: no prohibited comments added, no unhandled inputs or title-specific workarounds, no extra files or unauthorized submodule modifications.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6093119084 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/27924#pullrequestreview-6093119084). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-27T20:35:24Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `9ecd67a22e`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `guest_atoi_tests` built cleanly. - **CTest** (`guest_atoi`): ``` 1/1 Test #1482: guest_atoi ....................... Passed 0.01 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libc/src/HostErrno.cpp` reverted to `main` and the new tests kept, the suite fails: ``` 1/1 Test #1482: guest_atoi .......................***Failed 0.03 sec 0% tests passed, 1 tests failed out of 1 ``` Restoring the change makes it pass again. - **Code reading**: - Verified HostErrnoMap mappings in core/libs/prx/libc/src/HostErrno.cpp: ENODATA -> 1040, ENOSR -> 1050, ENOSTR -> 1051, EOTHER -> 1062, ETIME -> 1074 match the guest error codes defined in Errors.cpp. - Verified GuestErrnoFromHost_nid_no_patch linear search properly looks up the host errno and returns the mapped guest errno before the fallback bounds check error > 0 && error <= 34. - Verified all macros ENODATA, ENOSR, ENOSTR, EOTHER, and ETIME are cleanly wrapped with #ifdef guards for portability across Linux, Windows UCRT, and macOS. - Verified unit test core/libs/tests/GuestAtoi.cpp errnoCases[] adds valid regression cases exercising each newly mapped host error code against its expected guest integer value. - Verified compliance with AGENTS.md rules: no prohibited comments added, no unhandled inputs or title-specific workarounds, no extra files or unauthorized submodule modifications. Looks Good To Me
MarcZX10 commented 2026-11-27 20:52:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-27T20:52:34Z.

Review: APPROVED


Reviewed — looks good

The change maps the five guarded host errno values to the guest codes and adds matching cases to the existing errno test; both changed files were read at the pinned head.

What I ran

  • Read the prepared description, commit list, manifest, diff, and full text of both changed files through repo_read.py at head 9ecd67a22e8d56b35c56211455d8347f44c35f70.
  • No tests or build commands were run. No merged-preview check was run.

Results

Check Result Note
Changed-file review passed Both changed files read
Tests not run Test additions inspected only
Build and merged preview not run Not checked

Findings

Blocking

None.

Non-blocking

None.

Not verified

Runtime behavior and compilation on Windows UCRT, Linux, and macOS were not verified. Files listed in the manifest as reviewed: core/libs/prx/libc/src/HostErrno.cpp and core/libs/tests/GuestAtoi.cpp; both were read. No files were excluded by the manifest.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6093248200 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/27924#pullrequestreview-6093248200). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-27T20:52:34Z. **Review:** APPROVED --- # Reviewed — looks good The change maps the five guarded host errno values to the guest codes and adds matching cases to the existing errno test; both changed files were read at the pinned head. ## What I ran - Read the prepared description, commit list, manifest, diff, and full text of both changed files through `repo_read.py` at head `9ecd67a22e8d56b35c56211455d8347f44c35f70`. - No tests or build commands were run. No merged-preview check was run. ## Results | Check | Result | Note | |---|---|---| | Changed-file review | passed | Both changed files read | | Tests | not run | Test additions inspected only | | Build and merged preview | not run | Not checked | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified Runtime behavior and compilation on Windows UCRT, Linux, and macOS were not verified. Files listed in the manifest as reviewed: `core/libs/prx/libc/src/HostErrno.cpp` and `core/libs/tests/GuestAtoi.cpp`; both were read. No files were excluded by the manifest. ## To get this to a good state Nothing is required.
Plyxen commented 2026-11-28 05:06:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Plyxen on 2026-11-28T05:06:07Z.

Review: APPROVED


Checked head 9ecd67a22e. All on Windows 11 with WinLibs GCC 15.2 (Release), applied to main a163d4b886 together with #27930, #27929, #27926, #27925, #27923, #27922, #27901, #27828, #27771, #27755, #27748, #27682, #27765. tools/check_conventions.py --head and tools/debt_fold.py --check passed and the full build succeeded. guest_atoi passes, and the five values match the guest codes in Errors.cpp (1040, 1050, 1051, 1062, 1074). guest_resolver_system_errors also builds HostErrno.cpp, but it is registered only on Linux, so it did not run here. In the full CPU suite (5,120 tests) the only failures are unrelated:

  • windows_read_trap_unknown fails on main too (fixed in #28028).
  • frame_capture_minimize, jpeg_external_toolchain and guest_pthread_mutex_contention are timeouts under load; they pass when run on their own.
  • guest_audio_in_capture passes 20/20 on main and with #27922.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6095938377 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/27924#pullrequestreview-6095938377). Originally posted by [Plyxen](https://github.com/Plyxen) on 2026-11-28T05:06:07Z. **Review:** APPROVED --- Checked head `9ecd67a22e`. All on Windows 11 with WinLibs GCC 15.2 (Release), applied to `main` `a163d4b886` together with #27930, #27929, #27926, #27925, #27923, #27922, #27901, #27828, #27771, #27755, #27748, #27682, #27765. `tools/check_conventions.py --head` and `tools/debt_fold.py --check` passed and the full build succeeded. `guest_atoi` passes, and the five values match the guest codes in `Errors.cpp` (1040, 1050, 1051, 1062, 1074). `guest_resolver_system_errors` also builds `HostErrno.cpp`, but it is registered only on Linux, so it did not run here. In the full CPU suite (5,120 tests) the only failures are unrelated: - `windows_read_trap_unknown` fails on `main` too (fixed in #28028). - `frame_capture_minimize`, `jpeg_external_toolchain` and `guest_pthread_mutex_contention` are timeouts under load; they pass when run on their own. - `guest_audio_in_capture` passes 20/20 on `main` and with #27922. AI-assisted: yes (Claude Code)
ligmaSec commented 2026-12-03 08:16:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T08:16:34Z.

Review: COMMENTED


The GuestAtoi fixture passed with the exact HostErrno.cpp change linked into the Linux test. I checked the conditional host errno mappings. The run exercises the values defined by Linux glibc, and the Windows-only branch was outside this run.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6165950964 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/27924#pullrequestreview-6165950964). Originally posted by [ligmaSec](https://github.com/ligmaSec) on 2026-12-03T08:16:34Z. **Review:** COMMENTED --- The GuestAtoi fixture passed with the exact HostErrno.cpp change linked into the Linux test. I checked the conditional host errno mappings. The run exercises the values defined by Linux glibc, and the Windows-only branch was outside this run. AI-assisted: yes.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/27924:upstream-pr/27924'
git switch 'upstream-pr/27924'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/27924'
git switch 'upstream-pr/27924'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/27924'
git switch 'upstream-pr/27924'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/27924'
git switch 'main'
git merge --squash 'upstream-pr/27924'
git switch 'main'
git merge --ff-only 'upstream-pr/27924'
git switch 'main'
git merge 'upstream-pr/27924'
git push origin 'main'
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!27924
No description provided.