feat(libc): implement libc++ error category comparisons #26252

Merged
mihai1859 merged 2 commits from upstream-pr/26252 into main 2026-12-03 12:34:00 +00:00
mihai1859 commented 2026-11-23 14:57:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by mihai1859 on 2026-11-23T14:57:31Z.


What

Implements libc++’s base error_category::default_error_condition and both equivalent overloads imported by the separately converted Azahar core in #5927. The comparisons match the value and category identity. The condition overload calls the category’s virtual mapping, so subclass overrides are honoured.

The compiled PS5 Payload SDK v0.42 implementation confirms the 16-byte guest layout, the two-register return, and the virtual slot for the default mapping.

Tested

Windows 11 x64 and WinLibs GCC 16.2. guest_libc_static_imports passed with checks for the full signed value, both category and value mismatches, a virtual override that changes the category and value, and unreadable operands. Conventions and whitespace checks passed.

Using the same separately converted Azahar startup diagnostic and libkernel.prx, I compared patched libc.prx from main dfe428e798 and this change 6ff25ebc08. The startup diagnostic dropped from 205 to 202 unresolved names, with exactly the three targeted imports removed. A local merge check with #26224 also passed.

The overlap scan and manual comparison found no duplicate exports. #24322 and #24917 move the adjacent Threads.cpp entry in the libc CMake source list. If either lands first, keep the LibcxxErrorCategory.cpp entry when resolving that list.

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 the licence notice of code adapted from upstream (see AGENTS.md)
  • 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:5455476186 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/26252). Originally posted by [mihai1859](https://github.com/mihai1859) on 2026-11-23T14:57:31Z. --- ### What Implements libc++’s base `error_category::default_error_condition` and both `equivalent` overloads imported by the separately converted Azahar core in #5927. The comparisons match the value and category identity. The condition overload calls the category’s virtual mapping, so subclass overrides are honoured. The compiled PS5 Payload SDK v0.42 implementation confirms the 16-byte guest layout, the two-register return, and the virtual slot for the default mapping. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Windows 11 x64 and WinLibs GCC 16.2. `guest_libc_static_imports` passed with checks for the full signed value, both category and value mismatches, a virtual override that changes the category and value, and unreadable operands. Conventions and whitespace checks passed. Using the same separately converted Azahar startup diagnostic and `libkernel.prx`, I compared patched `libc.prx` from main `dfe428e798` and this change `6ff25ebc08`. The startup diagnostic dropped from 205 to 202 unresolved names, with exactly the three targeted imports removed. A local merge check with #26224 also passed. The overlap scan and manual comparison found no duplicate exports. #24322 and #24917 move the adjacent Threads.cpp entry in the libc CMake source list. If either lands first, keep the LibcxxErrorCategory.cpp entry when resolving that list. ### 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) and the licence notice of code adapted from upstream (see AGENTS.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 <!-- #PR, or none --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: none <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: n/a <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no -->
PrivacyOnion commented 2026-11-23 15:11:40 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-23T15:11:40Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 6ff25ebc08:

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_libc_static_imports_tests built cleanly.
  • CTest (guest_libc_static_imports):
    1/1 Test #1348: guest_libc_static_imports ........   Passed    0.11 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libc/include/Api.hpp, core/libs/prx/libc/src/LibcxxErrorCategory.cpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • Verified LibcxxErrorCondition layout (16 bytes, offset 8 for category pointer) against PS5/LLVM libc++ error_category and error_condition ABIs.
    • Audited GuestCopyIn_nid_no_patch error handling and pointer safety in ReadGuestValue across _ZNKSt3__114error_category10equivalentERKNS_10error_codeEi_nid_postfix and _ZNKSt3__114error_category10equivalentEiRKNS_15error_conditionE_nid_postfix.
    • Checked vtable offset 0x18 (DefaultConditionOffset) against the Itanium C++ ABI virtual function table layout for std::__1::error_category::default_error_condition(int).
    • Verified integer overflow guard and null pointer check for category vtable dereference in LibcxxErrorCategory.cpp.
    • Confirmed AGENTS.md compliance regarding no comments, debt fragment formatting in docs/dev/debt/changes/, and CMake build targets.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6024084674 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/26252#pullrequestreview-6024084674). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-23T15:11:40Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `6ff25ebc08`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `guest_libc_static_imports_tests` built cleanly. - **CTest** (`guest_libc_static_imports`): ``` 1/1 Test #1348: guest_libc_static_imports ........ Passed 0.11 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libc/include/Api.hpp`, `core/libs/prx/libc/src/LibcxxErrorCategory.cpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - Verified LibcxxErrorCondition layout (16 bytes, offset 8 for category pointer) against PS5/LLVM libc++ error_category and error_condition ABIs. - Audited GuestCopyIn_nid_no_patch error handling and pointer safety in ReadGuestValue across _ZNKSt3__114error_category10equivalentERKNS_10error_codeEi_nid_postfix and _ZNKSt3__114error_category10equivalentEiRKNS_15error_conditionE_nid_postfix. - Checked vtable offset 0x18 (DefaultConditionOffset) against the Itanium C++ ABI virtual function table layout for std::__1::error_category::default_error_condition(int). - Verified integer overflow guard and null pointer check for category vtable dereference in LibcxxErrorCategory.cpp. - Confirmed AGENTS.md compliance regarding no comments, debt fragment formatting in docs/dev/debt/changes/, and CMake build targets. Looks Good To Me
MarcZX10 commented 2026-11-25 08:14:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T08:14:36Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; the implementation and its focused tests support merging, with firmware export provenance and full title execution still unverified.

What I ran

Reviewed head 6ff25ebc0864064f6b39f15e044373265e343075 using repo_read.py. No tests or build commands were run in this review; the test and startup diagnostic results below are author-reported.

Results

Check Result Note
Diff and changed files passed All five changed files were read
Focused test execution not run Windows run reported by author
Console startup check not run Diagnostic reported by author

Findings

Blocking

None.

Non-blocking

  • The change documents that firmware export provenance and full title execution still need verification. Confirm these when suitable firmware and title coverage are available.

Not verified

No build, tests, firmware export inspection, console execution, or full title run was performed in this review. The author reports guest_libc_static_imports and conventions/whitespace checks passed on Windows 11 x64 with WinLibs GCC 16.2, and reports the startup diagnostic removed the three targeted unresolved imports. The review folder contained all five changed files, and each was read: core/libs/prx/libc/CMakeLists.txt, core/libs/prx/libc/include/Api.hpp, core/libs/prx/libc/src/LibcxxErrorCategory.cpp, core/libs/tests/GuestLibcStaticImports.cpp, and docs/dev/debt/changes/feat-libc-libcxx-error-category.md. No files were excluded.

To get this to a good state

Nothing is required. Optional: verify firmware export provenance and run the implementation in a full title execution when practical.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6053972183 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/26252#pullrequestreview-6053972183). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-25T08:14:36Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; the implementation and its focused tests support merging, with firmware export provenance and full title execution still unverified. ## What I ran Reviewed head `6ff25ebc0864064f6b39f15e044373265e343075` using `repo_read.py`. No tests or build commands were run in this review; the test and startup diagnostic results below are author-reported. ## Results | Check | Result | Note | |---|---|---| | Diff and changed files | passed | All five changed files were read | | Focused test execution | not run | Windows run reported by author | | Console startup check | not run | Diagnostic reported by author | ## Findings ### Blocking None. ### Non-blocking - The change documents that firmware export provenance and full title execution still need verification. Confirm these when suitable firmware and title coverage are available. ## Not verified No build, tests, firmware export inspection, console execution, or full title run was performed in this review. The author reports `guest_libc_static_imports` and conventions/whitespace checks passed on Windows 11 x64 with WinLibs GCC 16.2, and reports the startup diagnostic removed the three targeted unresolved imports. The review folder contained all five changed files, and each was read: `core/libs/prx/libc/CMakeLists.txt`, `core/libs/prx/libc/include/Api.hpp`, `core/libs/prx/libc/src/LibcxxErrorCategory.cpp`, `core/libs/tests/GuestLibcStaticImports.cpp`, and `docs/dev/debt/changes/feat-libc-libcxx-error-category.md`. No files were excluded. ## To get this to a good state Nothing is required. Optional: verify firmware export provenance and run the implementation in a full title execution when practical.
MarcZX10 commented 2026-11-25 13:33:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T13:33:31Z.

Review: APPROVED


Reviewed — looks good

The implementation’s comparisons and virtual default-condition mapping are supported by the inspected code; all five changed files were read, but no checks were run in this review.

What I ran

No commands or tests were run. I read the prepared description, commit list, manifest, diff, and all five changed files through repo_read.py at head 4e4c9890ed4f03092a1cba6036ce02606e4e76c5.

Results

Check Result Note
Changed code review passed All five changed files read
Tests and build not run Author-reported results not independently verified

Findings

Blocking

None.

Non-blocking

None.

Not verified

The author reports a passing guest_libc_static_imports test, conventions and whitespace checks, a startup diagnostic comparison, and a clean local merge check; these were not run or independently confirmed. Firmware export provenance and full title execution are also listed as needing verification in the changed debt note. No files were excluded from the review bundle.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6058554631 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/26252#pullrequestreview-6058554631). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-25T13:33:31Z. **Review:** APPROVED --- # Reviewed — looks good The implementation’s comparisons and virtual default-condition mapping are supported by the inspected code; all five changed files were read, but no checks were run in this review. ## What I ran No commands or tests were run. I read the prepared description, commit list, manifest, diff, and all five changed files through `repo_read.py` at head `4e4c9890ed4f03092a1cba6036ce02606e4e76c5`. ## Results | Check | Result | Note | |---|---|---| | Changed code review | passed | All five changed files read | | Tests and build | not run | Author-reported results not independently verified | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified The author reports a passing `guest_libc_static_imports` test, conventions and whitespace checks, a startup diagnostic comparison, and a clean local merge check; these were not run or independently confirmed. Firmware export provenance and full title execution are also listed as needing verification in the changed debt note. No files were excluded from the review bundle. ## To get this to a good state Nothing is required.
Plyxen commented 2026-12-03 07:35:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Plyxen on 2026-12-03T07:35:19Z.

Review: APPROVED


I read the diff at 4e4c9890ed. Merged into main at 35e34b1a7f0 together with other open PRs (so not an isolated build), Release, on Windows 11 (GCC 15.2) and Ubuntu 24.04 under WSL2 (GCC 13.3).

  • guest_libc_static_imports: passes on both.
  • The other guest_libcxx_* tests of that tree pass too (39 on Linux).
  • No control: the test needs exports that main does not have.

The Windows CI job was cancelled at its 90 minutes; the Windows run above covers this test only, not the whole suite.

Not checked: a title.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6165447881 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/26252#pullrequestreview-6165447881). Originally posted by [Plyxen](https://github.com/Plyxen) on 2026-12-03T07:35:19Z. **Review:** APPROVED --- I read the diff at `4e4c9890ed`. Merged into `main` at `35e34b1a7f0` together with other open PRs (so not an isolated build), Release, on Windows 11 (GCC 15.2) and Ubuntu 24.04 under WSL2 (GCC 13.3). - `guest_libc_static_imports`: passes on both. - The other `guest_libcxx_*` tests of that tree pass too (39 on Linux). - No control: the test needs exports that `main` does not have. The Windows CI job was cancelled at its 90 minutes; the Windows run above covers this test only, not the whole suite. Not checked: a title. AI-assisted: yes (Claude Code)
ligmaSec commented 2026-12-03 10:38:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T10:38:13Z.

Review: COMMENTED


The GuestLibcStaticImports fixture coverage passed on Linux with the exact implementation from this head. The fixture exercises comparison between error categories and conditions, including custom mappings.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6168111155 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/26252#pullrequestreview-6168111155). Originally posted by [ligmaSec](https://github.com/ligmaSec) on 2026-12-03T10:38:13Z. **Review:** COMMENTED --- The GuestLibcStaticImports fixture coverage passed on Linux with the exact implementation from this head. The fixture exercises comparison between error categories and conditions, including custom mappings. AI-assisted: yes.
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!26252
No description provided.