fix(libc): answer strerror as the titles' libc.prx does #10312

Merged
ntamas94 merged 1 commit from upstream-pr/10312 into main 2026-10-24 08:09:01 +00:00
ntamas94 commented 2026-10-23 17:27:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ntamas94 on 2026-10-23T17:27:53Z.


What

strerror now answers as the libc.prx that PS4 titles ship in sce_module/: 0 is "No error", 1 to 94 keep the FreeBSD texts (30 becomes "Read-only filesystem"), and every other number, 95 and 96 included, gives "error_code=0x%08x"; errno is no longer touched. On main it returned "No error: 0", named 95 and 96, answered "Unknown error: %d" and set errno to 22. strerror_r and perror keep their wording and errors; only the shared EROFS text changes for them, as it is the same table. guest_errors now expects these values for 0 to 96, 97, 9999, INT_MAX, -1 and INT_MIN, and checks that errno stays.

The console's system libc, which homebrew without a bundled libc.prx uses, answers differently ("No error information" for 0 and unknown numbers, 95 and 96 named); titles load their own module, so this follows the module. The debt entry records both.

Tested

Windows 11, MinGW-w64 GCC (winlibs), Ninja: guest_errors passed on the final head (8305168); with main's Errors.cpp it aborts. guest_err, which prints strerror texts, passes. python tools/check_conventions.py --base origin/main passes.

Measured on a PS4 Pro (firmware 10.71): the bundled libc.prx of CUSA04865 and of CUSA12435 (two different builds of the module), my own dumps, fake-signed and loaded into a homebrew process with sceKernelLoadStartModule next to the system libc (different sceKernelDlsym addresses for each module). Both give the same rows; errno was set to 1234 before each call and read back:

title strerror(0) errno 1234->1234 "No error"
title strerror(1) errno 1234->1234 "Operation not permitted"
title strerror(30) errno 1234->1234 "Read-only filesystem"
title strerror(94) errno 1234->1234 "Not permitted in capability mode"
title strerror(95) errno 1234->1234 "error_code=0x0000005f"
title strerror(96) errno 1234->1234 "error_code=0x00000060"
title strerror(-1) errno 1234->1234 "error_code=0xffffffff"
title strerror(9999) errno 1234->1234 "error_code=0x0000270f"

Every number from 1 to 94 matches the existing table word for word except 30. Not run with a title.

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 under Silent stubs in their library's technical debt file
  • 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
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4986721269 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10312). Originally posted by [ntamas94](https://github.com/ntamas94) on 2026-10-23T17:27:53Z. --- ### What `strerror` now answers as the `libc.prx` that PS4 titles ship in `sce_module/`: 0 is "No error", 1 to 94 keep the FreeBSD texts (30 becomes "Read-only filesystem"), and every other number, 95 and 96 included, gives "error_code=0x%08x"; errno is no longer touched. On `main` it returned "No error: 0", named 95 and 96, answered "Unknown error: %d" and set errno to 22. `strerror_r` and `perror` keep their wording and errors; only the shared EROFS text changes for them, as it is the same table. `guest_errors` now expects these values for 0 to 96, 97, 9999, `INT_MAX`, -1 and `INT_MIN`, and checks that errno stays. The console's system libc, which homebrew without a bundled `libc.prx` uses, answers differently ("No error information" for 0 and unknown numbers, 95 and 96 named); titles load their own module, so this follows the module. The debt entry records both. ### Tested Windows 11, MinGW-w64 GCC (winlibs), Ninja: `guest_errors` passed on the final head (8305168); with `main`'s `Errors.cpp` it aborts. `guest_err`, which prints `strerror` texts, passes. `python tools/check_conventions.py --base origin/main` passes. Measured on a PS4 Pro (firmware 10.71): the bundled `libc.prx` of CUSA04865 and of CUSA12435 (two different builds of the module), my own dumps, fake-signed and loaded into a homebrew process with `sceKernelLoadStartModule` next to the system libc (different `sceKernelDlsym` addresses for each module). Both give the same rows; errno was set to 1234 before each call and read back: ``` title strerror(0) errno 1234->1234 "No error" title strerror(1) errno 1234->1234 "Operation not permitted" title strerror(30) errno 1234->1234 "Read-only filesystem" title strerror(94) errno 1234->1234 "Not permitted in capability mode" title strerror(95) errno 1234->1234 "error_code=0x0000005f" title strerror(96) errno 1234->1234 "error_code=0x00000060" title strerror(-1) errno 1234->1234 "error_code=0xffffffff" title strerror(9999) errno 1234->1234 "error_code=0x0000270f" ``` Every number from 1 to 94 matches the existing table word for word except 30. Not run with a title. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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 under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [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] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-10-23 21:22:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T21:22:21Z.

Review: APPROVED


Reviewed the changed strerror path, tests, and debt note. The measured bundled-module behavior is separated clearly from system-libc behavior, and the implementation preserves errno while formatting unknown and out-of-range values as unsigned 32-bit hex. The regression test covers 0..96 plus large positive/negative boundaries and verifies errno preservation; strerror_r retains its prior unknown-error contract. The strerror change only changes the shared EROFS message used by strerror_r/perror, which is called out. Hosted eligibility, conventions, intake, labels, relinker matrix, and auxiliary checks pass; full Linux/Windows jobs were skipped by workflow policy. No blocking issue found in the reviewed diff.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5634583461 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10312#pullrequestreview-5634583461). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-23T21:22:21Z. **Review:** APPROVED --- Reviewed the changed `strerror` path, tests, and debt note. The measured bundled-module behavior is separated clearly from system-libc behavior, and the implementation preserves errno while formatting unknown and out-of-range values as unsigned 32-bit hex. The regression test covers 0..96 plus large positive/negative boundaries and verifies errno preservation; `strerror_r` retains its prior unknown-error contract. The `strerror` change only changes the shared EROFS message used by strerror_r/perror, which is called out. Hosted eligibility, conventions, intake, labels, relinker matrix, and auxiliary checks pass; full Linux/Windows jobs were skipped by workflow policy. No blocking issue found in the reviewed diff.
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!10312
No description provided.