feat(libSceLibcInternal): forward error category destructors and overflow errors #15697

Merged
B-Howell merged 7 commits from upstream-pr/15697 into main 2026-11-08 18:15:19 +00:00
B-Howell commented 2026-11-04 07:30:30 +00:00 (Migrated from github.com)

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


What

Implements five existing libSceLibcInternal stubs using the corresponding libc behavior.

Export NID Stub on main Now runs
_ZNSt22_Future_error_categoryD0Ev WDKzMM-uuLE libSceLibcInternalInventory_054 libc _ZNSt14error_categoryD2Ev, then _ZdlPv
_ZNSt22_System_error_categoryD0Ev Dc4ZMWmPMl8 libSceLibcInternalInventory_055 libc _ZNSt14error_categoryD2Ev, then _ZdlPv
_ZNSt22_System_error_categoryD1Ev hVQgfGhJz3U libSceLibcInternalInventory_056 libc _ZNSt14error_categoryD2Ev
_ZNSt23_Generic_error_categoryD1Ev MAalgQhejPc libSceLibcInternalInventory_057 libc _ZNSt14error_categoryD2Ev
_ZSt16_Xoverflow_errorPKc saSUnPWLq9E libSceLibcInternalInventory_242 throws std::overflow_error through libc's _X thrower helper
  • Category destructors: microsoft/STL at 54d74d7a58e8 gives error_category a defaulted virtual destructor, _CONSTEXPR20 virtual ~error_category() noexcept = default; (stl/inc/system_error L91), and the derived categories declare none of their own. libc already exports that destructor as _ZNSt14error_categoryD2Ev with an empty body (core/libs/prx/libc/src/exception/StandardExceptions.cpp), so D1 runs it. The Itanium C++ ABI defines the deleting destructor as the complete-object destructor followed by the deallocation function, so D0 runs it and then libc operator delete(void*) (_ZdlPv).
  • _Xoverflow_error: microsoft/STL stl/src/xthrow.cpp L26-L28 is _THROW(overflow_error(_Message));. libc throws its other unversioned _X errors (_Xinvalid_argument, _Xruntime_error, _Xrange_error) with LibcException::ThrowMessage and the matching vtable. This PR adds LibcThrowOverflowError_nid_no_patch next to them in StandardExceptions.cpp, with _ZTVSt14overflow_error_nid_postfix, and the export calls it, so the guest catches std::overflow_error (unversioned), as the mangled name St14overflow_error says.

The mutex name override landed separately in #16029. This branch uses that implementation from main and retains the guest mutex integration test. The progress report counts five additional implementations. Console ABI for the five forwards remains unverified.

Tested

  • Hosted checks pass on the current head 45c2968563. Dean’s latest change removes the duplicate mutex debt entry. The fixture continues to exercise category destruction, overflow exception handling, and the upstream mutex integration.
  • On earlier head ca6321bbfd, Windows and WSL each passed five focused selectors 3/3 and public headers 65/65.
  • Dean ran a 20-test GCC Linux selection on a7fa6cf6a7.
  • The independent Windows retest on 183889c23b passed guest_libc_internal_libc_forwards 3/3 under WinLibs GCC 15.2 UCRT.

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:5150632352 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15697). Originally posted by [B-Howell](https://github.com/B-Howell) on 2026-11-04T07:30:30Z. --- ### What Implements five existing `libSceLibcInternal` stubs using the corresponding `libc` behavior. | Export | NID | Stub on `main` | Now runs | |---|---|---|---| | `_ZNSt22_Future_error_categoryD0Ev` | `WDKzMM-uuLE` | `libSceLibcInternalInventory_054` | `libc` `_ZNSt14error_categoryD2Ev`, then `_ZdlPv` | | `_ZNSt22_System_error_categoryD0Ev` | `Dc4ZMWmPMl8` | `libSceLibcInternalInventory_055` | `libc` `_ZNSt14error_categoryD2Ev`, then `_ZdlPv` | | `_ZNSt22_System_error_categoryD1Ev` | `hVQgfGhJz3U` | `libSceLibcInternalInventory_056` | `libc` `_ZNSt14error_categoryD2Ev` | | `_ZNSt23_Generic_error_categoryD1Ev` | `MAalgQhejPc` | `libSceLibcInternalInventory_057` | `libc` `_ZNSt14error_categoryD2Ev` | | `_ZSt16_Xoverflow_errorPKc` | `saSUnPWLq9E` | `libSceLibcInternalInventory_242` | throws `std::overflow_error` through `libc`'s `_X` thrower helper | - Category destructors: microsoft/STL at `54d74d7a58e8` gives `error_category` a defaulted virtual destructor, `_CONSTEXPR20 virtual ~error_category() noexcept = default;` ([`stl/inc/system_error` L91](https://github.com/microsoft/STL/blob/54d74d7a58e828857a73f979eccc2ba1c02e256d/stl/inc/system_error#L91)), and the derived categories declare none of their own. `libc` already exports that destructor as `_ZNSt14error_categoryD2Ev` with an empty body (`core/libs/prx/libc/src/exception/StandardExceptions.cpp`), so `D1` runs it. The [Itanium C++ ABI](https://itanium-cxx-abi.github.io/cxx-abi/abi.html#definitions) defines the deleting destructor as the complete-object destructor followed by the deallocation function, so `D0` runs it and then `libc` `operator delete(void*)` (`_ZdlPv`). - `_Xoverflow_error`: microsoft/STL [`stl/src/xthrow.cpp` L26-L28](https://github.com/microsoft/STL/blob/54d74d7a58e828857a73f979eccc2ba1c02e256d/stl/src/xthrow.cpp#L26-L28) is `_THROW(overflow_error(_Message));`. `libc` throws its other unversioned `_X` errors (`_Xinvalid_argument`, `_Xruntime_error`, `_Xrange_error`) with `LibcException::ThrowMessage` and the matching vtable. This PR adds `LibcThrowOverflowError_nid_no_patch` next to them in `StandardExceptions.cpp`, with `_ZTVSt14overflow_error_nid_postfix`, and the export calls it, so the guest catches `std::overflow_error` (unversioned), as the mangled name `St14overflow_error` says. The mutex name override landed separately in [#16029](https://github.com/boykopovar/AnyPS5/pull/16029). This branch uses that implementation from `main` and retains the guest mutex integration test. The [progress report](https://github.com/boykopovar/AnyPS5/pull/15697#issuecomment-6625285449) counts five additional implementations. Console ABI for the five forwards remains unverified. ### 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. --> - Hosted checks pass on the current head `45c2968563`. Dean’s latest change removes the duplicate mutex debt entry. The fixture continues to exercise category destruction, overflow exception handling, and the upstream mutex integration. - On earlier head `ca6321bbfd`, Windows and WSL each passed five focused selectors 3/3 and public headers 65/65. - Dean [ran a 20-test GCC Linux selection](https://github.com/boykopovar/AnyPS5/pull/15697#issuecomment-6712788515) on `a7fa6cf6a7`. - The [independent Windows retest](https://github.com/boykopovar/AnyPS5/pull/15697#issuecomment-6625761903) on `183889c23b` passed `guest_libc_internal_libc_forwards` 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!15697
No description provided.