feat(libSceLibcInternal): implement the error category names and codecvt_base queries #15696

Merged
B-Howell merged 6 commits from upstream-pr/15696 into main 2026-11-09 07:29:25 +00:00
B-Howell commented 2026-11-04 07:30:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by B-Howell on 2026-11-04T07:30:18Z.


What

Implements six libSceLibcInternal exports that were stubs throwing through NotImplemented_nid_no_patch. Each mangled name was checked against its NID with tools/nid_names.py's compute_nid:

Export NID Returns
_ZNKSt22_System_error_category4nameEv dXy+lFOiaQA "system"
_ZNKSt23_Generic_error_category4nameEv xvVR0CBPFAM "generic"
_ZNKSt24_Iostream_error_category4nameEv sb2vivqtLS0 "iostream"
_ZNKSt22_Future_error_category4nameEv Q0VsWTapQ4M "future"
_ZNKSt12codecvt_base13do_max_lengthEv FOsY+JAyXow 1
_ZNKSt12codecvt_base11do_encodingEv MwAySqTo+-M 1

Where the behaviour comes from:

  • ISO C++ sets the category names: [syserr.errcat.objects] says the generic and system category objects' name returns "generic" and "system", [iostreams.base] gives "iostream" for iostream_category(), and [futures.errors] gives "future" for future_category(). The same strings appear in microsoft/STL at e1ed302683e5e822f663fbb0f44cee7e9ddc6af0: stl/inc/system_error L549 return "generic";, L562 return "iostream";, L579 return "system";, and stl/inc/future L152 return "future";. They also match the existing AnyPS5 guest category vtables in libc/src/exception/StandardExceptions.cpp (GenericCategoryName_nid_no_patch returns "generic", SystemCategoryName_nid_no_patch returns "system" and FutureCategoryName_nid_no_patch returns "future").
  • codecvt_base: in microsoft/STL stl/inc/xlocale L608-L615 at the same commit, virtual int __CLR_OR_THIS_CALL do_max_length() const noexcept and do_encoding() const noexcept both return 1;. This also matches AnyPS5's own codecvt facet in libc/src/LocaleSupport.cpp, where CodecvtConstantOne returns 1 and fills both the max_length and encoding slots of g_codecvtVtable.

None of the six functions reads its object. The stubs are removed from InventoryExports.cpp, InventoryExports2.cpp and InventoryExports.hpp, and the new functions are declared once in include/Api.hpp. The debt file loses these NIDs from its stub entries and gains one entry for what is still unverified: the console's libSceLibcInternal.sprx was not compared and no title was seen calling these exports.

Who calls them: name() is the virtual a program calls to label an error_category, for example when it prints a code as category().name() and value(). system_error::what() does not read it: microsoft/STL at e1ed302683e5 builds the message from _Errcode.message() (stl/inc/system_error L467-L478). The codecvt_base queries are what a stream asks its codecvt facet for max_length and encoding.

tools/progress.py collect_libraries(), current origin/main 5b1d381d5a against this branch merged into it (it merges cleanly): done goes from 9913 to 9919 (+6) with total unchanged at 37146. For libSceLibcInternal, done goes from 92 to 98 and todo from 1045 to 1039, so no todo is added.

Tested

  • New guest test guest_libc_internal_constant_members (core/libs/tests/GuestLibcInternalConstantMembers.cpp). It checks each name string, checks that the result does not depend on the object passed (null, an unrelated object, the real category), compares each name with the name slot of libc's guest generic_category(), system_category() and future_category() vtables, and checks that both codecvt_base queries return 1.

  • Windows 11, WinLibs GCC 15.2.0, Release, commit 9cd64b09c8: guest_libc_internal_constant_members, guest_libc_internal_exception_destructors and public_headers (the single-declaration check) were run 3 times; 3/3 passed each time (9/9).

  • Linux, WSL Ubuntu 22.04.1, GCC 11.4.0, Release, same commit: the same 3 tests were run 3 times; 3/3 passed each time (9/9).

  • The branch is based on b8efa6292a and merges into current main (5b1d381d5a) without conflicts (git merge-tree), so it was not rebased again.

  • Negative control: main's production files (the stub InventoryExports.cpp, InventoryExports2.cpp and InventoryExports.hpp, with no implementation) plus the new test fail to link on both Windows and Linux. All six functions are reported as undefined reference.

  • MSYS_NO_PATHCONV=1 python3 tools/check_conventions.py --base origin/main with this title and body printed "All conventions checks passed." The conventions_* and debt_split ctest entries are self-tests of the checker scripts and were not run separately.

  • python3 tools/pr_overlap.py --branch feat/lci-errcat-names probed 1805 open PRs. No open PR implements these NIDs. Its table lists #13486 under "Same exports" with the old libSceLibcInternalInventory_001_nid_no_patch name and the new sceLibcInternalSystemErrorCategoryName_nid_no_patch only because its base is stale; its own diff touches only core/relinker. #14373 and #14834 edit neighbouring lines in include/Api.hpp (L123); whichever merges second needs a trivial rebase. It then reported:

    pr_overlap: cannot confirm overlap with PR 5021: core/libs/prx/libSceLibcInternal/CMakeLists.txt, docs/dev/debt/libSceLibcInternal.md
    pr_overlap: cannot confirm overlap with PR 13486: core/libs/prx/libSceLibcInternal/CMakeLists.txt, core/libs/prx/libSceLibcInternal/InventoryExports.cpp, core/libs/prx/libSceLibcInternal/include/Api.hpp, core/libs/prx/libSceLibcInternal/include/InventoryExports.hpp, docs/dev/debt/libSceLibcInternal.md
    pr_overlap: cannot confirm overlap with PR 13778: core/libs/prx/libSceLibcInternal/CMakeLists.txt, core/libs/prx/libSceLibcInternal/InventoryExports.cpp, core/libs/prx/libSceLibcInternal/include/Api.hpp, core/libs/prx/libSceLibcInternal/include/InventoryExports.hpp, docs/dev/debt/libSceLibcInternal.md
    pr_overlap: cannot confirm overlap with PR 13782: core/libs/prx/libSceLibcInternal/CMakeLists.txt, docs/dev/debt/libSceLibcInternal.md
    pr_overlap: cannot confirm overlap with PR 13881: core/libs/prx/libSceLibcInternal/InventoryExports.cpp, core/libs/prx/libSceLibcInternal/include/Api.hpp, core/libs/prx/libSceLibcInternal/include/InventoryExports.hpp, docs/dev/debt/libSceLibcInternal.md
    pr_overlap: cannot confirm overlap with PR 14085: docs/dev/debt/libSceLibcInternal.md
    pr_overlap: cannot confirm overlap with PR 14212: docs/dev/debt/libSceLibcInternal.md
    pr_overlap: cannot confirm overlap with PR 14401: core/libs/prx/libSceLibcInternal/CMakeLists.txt, core/libs/prx/libSceLibcInternal/InventoryExports.cpp, core/libs/prx/libSceLibcInternal/include/InventoryExports.hpp, docs/dev/debt/libSceLibcInternal.md
    pr_overlap: cannot confirm overlap with PR 14837: core/libs/prx/libSceLibcInternal/CMakeLists.txt, core/libs/prx/libSceLibcInternal/InventoryExports.cpp, core/libs/prx/libSceLibcInternal/include/Api.hpp, core/libs/prx/libSceLibcInternal/include/InventoryExports.hpp, docs/dev/debt/libSceLibcInternal.md
    pr_overlap: cannot confirm overlap with PR 14936: core/libs/prx/libSceLibcInternal/CMakeLists.txt, core/libs/prx/libSceLibcInternal/InventoryExports.cpp, core/libs/prx/libSceLibcInternal/include/InventoryExports.hpp, docs/dev/debt/libSceLibcInternal.md
    pr_overlap: overlap check failed closed; manually compare every reported PR branch before opening this one
    
  • Manual comparison of those ten PRs plus #14373 and #14834. For each I took its diff (gh pr diff; for #5021, which is too large for that, the libSceLibcInternal file patches from the pull request files API) and searched every added and removed line for the six NIDs, the six mangled names, the six stub names this PR removes and ConstantMembers. None has a hit: #5021, #13486, #13778, #13782, #13881, #14085, #14212, #14401, #14837, #14936, #14373 and #14834. So none implements these functions or edits the stub lines this PR removes.

  • No title run.

Independent test evidence

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

🤖 Generated with Claude Code

🤖 Updated with Codex

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5150630066 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15696). Originally posted by [B-Howell](https://github.com/B-Howell) on 2026-11-04T07:30:18Z. --- ### What Implements six `libSceLibcInternal` exports that were stubs throwing through `NotImplemented_nid_no_patch`. Each mangled name was checked against its NID with `tools/nid_names.py`'s `compute_nid`: | Export | NID | Returns | | --- | --- | --- | | `_ZNKSt22_System_error_category4nameEv` | `dXy+lFOiaQA` | `"system"` | | `_ZNKSt23_Generic_error_category4nameEv` | `xvVR0CBPFAM` | `"generic"` | | `_ZNKSt24_Iostream_error_category4nameEv` | `sb2vivqtLS0` | `"iostream"` | | `_ZNKSt22_Future_error_category4nameEv` | `Q0VsWTapQ4M` | `"future"` | | `_ZNKSt12codecvt_base13do_max_lengthEv` | `FOsY+JAyXow` | `1` | | `_ZNKSt12codecvt_base11do_encodingEv` | `MwAySqTo+-M` | `1` | Where the behaviour comes from: - ISO C++ sets the category names: [syserr.errcat.objects] says the generic and system category objects' `name` returns `"generic"` and `"system"`, [iostreams.base] gives `"iostream"` for `iostream_category()`, and [futures.errors] gives `"future"` for `future_category()`. The same strings appear in microsoft/STL at `e1ed302683e5e822f663fbb0f44cee7e9ddc6af0`: `stl/inc/system_error` L549 `return "generic";`, L562 `return "iostream";`, L579 `return "system";`, and `stl/inc/future` L152 `return "future";`. They also match the existing AnyPS5 guest category vtables in `libc/src/exception/StandardExceptions.cpp` (`GenericCategoryName_nid_no_patch` returns `"generic"`, `SystemCategoryName_nid_no_patch` returns `"system"` and `FutureCategoryName_nid_no_patch` returns `"future"`). - `codecvt_base`: in microsoft/STL `stl/inc/xlocale` L608-L615 at the same commit, `virtual int __CLR_OR_THIS_CALL do_max_length() const noexcept` and `do_encoding() const noexcept` both `return 1;`. This also matches AnyPS5's own codecvt facet in `libc/src/LocaleSupport.cpp`, where `CodecvtConstantOne` returns 1 and fills both the `max_length` and `encoding` slots of `g_codecvtVtable`. None of the six functions reads its object. The stubs are removed from `InventoryExports.cpp`, `InventoryExports2.cpp` and `InventoryExports.hpp`, and the new functions are declared once in `include/Api.hpp`. The debt file loses these NIDs from its stub entries and gains one entry for what is still unverified: the console's `libSceLibcInternal.sprx` was not compared and no title was seen calling these exports. Who calls them: `name()` is the virtual a program calls to label an `error_category`, for example when it prints a code as `category().name()` and `value()`. `system_error::what()` does not read it: microsoft/STL at `e1ed302683e5` builds the message from `_Errcode.message()` (`stl/inc/system_error` L467-L478). The `codecvt_base` queries are what a stream asks its codecvt facet for `max_length` and `encoding`. `tools/progress.py` `collect_libraries()`, current `origin/main` `5b1d381d5a` against this branch merged into it (it merges cleanly): `done` goes from 9913 to 9919 (+6) with `total` unchanged at 37146. For `libSceLibcInternal`, `done` goes from 92 to 98 and `todo` from 1045 to 1039, so no todo is added. ### 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. --> - New guest test `guest_libc_internal_constant_members` (`core/libs/tests/GuestLibcInternalConstantMembers.cpp`). It checks each name string, checks that the result does not depend on the object passed (null, an unrelated object, the real category), compares each name with the `name` slot of libc's guest `generic_category()`, `system_category()` and `future_category()` vtables, and checks that both `codecvt_base` queries return 1. - Windows 11, WinLibs GCC 15.2.0, Release, commit `9cd64b09c8`: `guest_libc_internal_constant_members`, `guest_libc_internal_exception_destructors` and `public_headers` (the single-declaration check) were run 3 times; 3/3 passed each time (9/9). - Linux, WSL Ubuntu 22.04.1, GCC 11.4.0, Release, same commit: the same 3 tests were run 3 times; 3/3 passed each time (9/9). - The branch is based on `b8efa6292a` and merges into current `main` (`5b1d381d5a`) without conflicts (`git merge-tree`), so it was not rebased again. - Negative control: `main`'s production files (the stub `InventoryExports.cpp`, `InventoryExports2.cpp` and `InventoryExports.hpp`, with no implementation) plus the new test fail to link on both Windows and Linux. All six functions are reported as `undefined reference`. - `MSYS_NO_PATHCONV=1 python3 tools/check_conventions.py --base origin/main` with this title and body printed "All conventions checks passed." The `conventions_*` and `debt_split` ctest entries are self-tests of the checker scripts and were not run separately. - `python3 tools/pr_overlap.py --branch feat/lci-errcat-names` probed 1805 open PRs. No open PR implements these NIDs. Its table lists #13486 under "Same exports" with the old `libSceLibcInternalInventory_001_nid_no_patch` name and the new `sceLibcInternalSystemErrorCategoryName_nid_no_patch` only because its base is stale; its own diff touches only `core/relinker`. #14373 and #14834 edit neighbouring lines in `include/Api.hpp` (L123); whichever merges second needs a trivial rebase. It then reported: ``` pr_overlap: cannot confirm overlap with PR 5021: core/libs/prx/libSceLibcInternal/CMakeLists.txt, docs/dev/debt/libSceLibcInternal.md pr_overlap: cannot confirm overlap with PR 13486: core/libs/prx/libSceLibcInternal/CMakeLists.txt, core/libs/prx/libSceLibcInternal/InventoryExports.cpp, core/libs/prx/libSceLibcInternal/include/Api.hpp, core/libs/prx/libSceLibcInternal/include/InventoryExports.hpp, docs/dev/debt/libSceLibcInternal.md pr_overlap: cannot confirm overlap with PR 13778: core/libs/prx/libSceLibcInternal/CMakeLists.txt, core/libs/prx/libSceLibcInternal/InventoryExports.cpp, core/libs/prx/libSceLibcInternal/include/Api.hpp, core/libs/prx/libSceLibcInternal/include/InventoryExports.hpp, docs/dev/debt/libSceLibcInternal.md pr_overlap: cannot confirm overlap with PR 13782: core/libs/prx/libSceLibcInternal/CMakeLists.txt, docs/dev/debt/libSceLibcInternal.md pr_overlap: cannot confirm overlap with PR 13881: core/libs/prx/libSceLibcInternal/InventoryExports.cpp, core/libs/prx/libSceLibcInternal/include/Api.hpp, core/libs/prx/libSceLibcInternal/include/InventoryExports.hpp, docs/dev/debt/libSceLibcInternal.md pr_overlap: cannot confirm overlap with PR 14085: docs/dev/debt/libSceLibcInternal.md pr_overlap: cannot confirm overlap with PR 14212: docs/dev/debt/libSceLibcInternal.md pr_overlap: cannot confirm overlap with PR 14401: core/libs/prx/libSceLibcInternal/CMakeLists.txt, core/libs/prx/libSceLibcInternal/InventoryExports.cpp, core/libs/prx/libSceLibcInternal/include/InventoryExports.hpp, docs/dev/debt/libSceLibcInternal.md pr_overlap: cannot confirm overlap with PR 14837: core/libs/prx/libSceLibcInternal/CMakeLists.txt, core/libs/prx/libSceLibcInternal/InventoryExports.cpp, core/libs/prx/libSceLibcInternal/include/Api.hpp, core/libs/prx/libSceLibcInternal/include/InventoryExports.hpp, docs/dev/debt/libSceLibcInternal.md pr_overlap: cannot confirm overlap with PR 14936: core/libs/prx/libSceLibcInternal/CMakeLists.txt, core/libs/prx/libSceLibcInternal/InventoryExports.cpp, core/libs/prx/libSceLibcInternal/include/InventoryExports.hpp, docs/dev/debt/libSceLibcInternal.md pr_overlap: overlap check failed closed; manually compare every reported PR branch before opening this one ``` - Manual comparison of those ten PRs plus #14373 and #14834. For each I took its diff (`gh pr diff`; for #5021, which is too large for that, the `libSceLibcInternal` file patches from the pull request files API) and searched every added and removed line for the six NIDs, the six mangled names, the six stub names this PR removes and `ConstantMembers`. None has a hit: #5021, #13486, #13778, #13782, #13881, #14085, #14212, #14401, #14837, #14936, #14373 and #14834. So none implements these functions or edits the stub lines this PR removes. - No title run. #### Independent test evidence - [Independent Windows check](https://github.com/boykopovar/AnyPS5/pull/15696#issuecomment-6625761559) on `9cd64b09c8`: `guest_libc_internal_constant_members` passed 3/3 under WinLibs GCC 15.2 UCRT. ### 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 <!-- #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 --> 🤖 Generated with [Claude Code](https://claude.com/claude-code) 🤖 Updated with [Codex](https://openai.com/codex)
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!15696
No description provided.