feat(libSceLibcInternal): run the C++ ABI type_info destructors #15695

Merged
B-Howell merged 2 commits from upstream-pr/15695 into main 2026-11-07 18:14:39 +00:00
B-Howell commented 2026-11-04 07:30:06 +00:00 (Migrated from github.com)

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


What

Implements the base-object (D2), complete-object (D1) and deleting (D0) destructors of all ten __cxxabiv1 RTTI classes in libSceLibcInternal. On main these were 30 parameterless sceLibcInternalUnknown_* stubs in InventoryExports2.cpp that threw through NotImplemented_nid_no_patch:

Class D2 D1 D0
__fundamental_type_info 0jk9oqKd2Gw kzWL2iOsv0E YsZuwZrJZlU
__array_type_info ckFrsyD2830 1ZMchlkvNNQ R5nRbLQT3oI
__function_type_info NtqD4Q0vUUI dsQ5Xwhl9no kVvGL9aF5gg
__enum_type_info iQiT26+ZGnA upwSZWmYwqE CjzjU2nFUWw
__class_type_info xXM1q-ayw2Y goLVqD-eiIY XAk7W3NcpTY
__si_class_type_info bWHwovVFfqc 6aEkwkEOGRg Fg4w+h9wAMA
__vmi_class_type_info yYIymfQGl2E h-a7+0UuK7Q W5k0jlyBpgM
__pbase_type_info krshE4JAE6M vIJPARS8imE GLxD5v2uMHw
__pointer_type_info vCLVhOcdQMY bhfgrK+MZdk 64180GwMVro
__pointer_to_member_type_info Re3Lpk8mwEo KaZ3xf5c9Vc NdeDffcZ-30

The mangled names are _ZN10__cxxabiv1<N><class>D<k>Ev, for example _ZN10__cxxabiv117__array_type_infoD0Ev; the NIDs are the ones docs/dev/debt/libSceLibcInternal.md listed for those names on main. Each export takes this as its only argument (void(void* self)).

Where the behaviour comes from, for every class:

  • The Itanium C++ ABI defines these ten classes with virtual destructors. Its definitions make the deleting destructor the complete-object destructor followed by the class's deallocation function, which for these classes is the global operator delete.
  • LLVM libc++abi gives all ten destructors empty bodies: private_typeinfo.cpp L330-L386 at llvmorg-18.1.8, from __fundamental_type_info::~__fundamental_type_info() (L330) to __pointer_to_member_type_info::~__pointer_to_member_type_info() (L384), each followed by an empty { }. None of the classes owns anything.
  • libc already treats in-place destruction of guest RTTI as a no-op: the destroy slot of every libc RTTI vtable is LibcException::DestroyTypeInfo (core/libs/prx/libc/src/exception/TypeInfo.cpp), whose body is empty. It is in an anonymous namespace there, so these exports do not call it; they do the same nothing.

So D1 and D2 leave the object as it is, and D0 then frees it through libc's operator delete(void*) (_ZdlPv_nid_postfix, declared in core/libs/prx/libc/include/Api.hpp). All 30 exports are in one new file, TypeInfoDestructors.cpp, and go through one helper, RunTypeInfoDestructor(self, deleting). They are declared once in include/Api.hpp.

libc's own DeleteTypeInfo throws "deleting guest RTTI is not supported", because the only objects with that vtable are libc's static records. These exports do not copy that throw. That difference, and the fact that the console's libSceLibcInternal.sprx was not read (so whether its D0 frees from the same heap as libc.prx, or calls the sized operator delete, is unverified), are recorded in one new entry in docs/dev/debt/libSceLibcInternal.md. The 30 names leave the "Additional 3.20 imports" stub lists there.

This PR replaces four local branches (feat/lci-typeinfo-a to -d, never opened) that created the same files and edited the same lines.

tools/progress.py collect_libraries(), origin/main 5b1d381d5a against this branch: libSceLibcInternal done 92 -> 122 (+30), todo 1045 -> 1015 (-30). The repository total goes from 9913 to 9943 done of 37146 (26.69% -> 26.77%), so +30 done and no new todo.

Tested

  • New guest test guest_libc_internal_type_info_destructors (core/libs/tests/GuestLibcInternalTypeInfoDestructors.cpp). It registers a counting application heap and checks all ten classes with a record of each class's ABI size (16 bytes for the five classes with only vtable and name, 24 for __si_class_type_info, 56 for a two-base __vmi_class_type_info, 32 for __pbase_type_info and __pointer_type_info, 40 for __pointer_to_member_type_info):

    • D2 and D1 are each called twice on the record. Its bytes must not change and nothing may be released.
    • D0 is called on a record from libc operator new (_Znwm). Exactly that pointer must be released, once, through the heap's free.
    • D0 on a null pointer must release nothing, as operator delete of null does.
  • Windows 11, WinLibs GCC 15.2.0, Release, commit bccff50560: guest_libc_internal_type_info_destructors, 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).

  • Negative control on Windows: main's InventoryExports2.cpp was put back, TypeInfoDestructors.cpp was emptied and the new test was kept. The test target fails to link with undefined reference to all 30 sceLibcInternal*TypeInfo*Destructor_nid_no_patch symbols.

  • MSYS_NO_PATHCONV=1 python3 tools/check_conventions.py --base origin/main with this title and body printed "All conventions checks passed."

  • python3 tools/pr_overlap.py --branch feat/lci-typeinfo-destructors probed 1804 open PRs. No open PR has the same exports or the same new files. Its table lists PRs that edit neighbouring lines only: #14373 and #14834 (include/Api.hpp L123 and the debt file L534) and #15692 (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/include/Api.hpp, docs/dev/debt/libSceLibcInternal.md
    pr_overlap: cannot confirm overlap with PR 13778: core/libs/prx/libSceLibcInternal/CMakeLists.txt, core/libs/prx/libSceLibcInternal/include/Api.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/include/Api.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, docs/dev/debt/libSceLibcInternal.md
    pr_overlap: cannot confirm overlap with PR 14837: core/libs/prx/libSceLibcInternal/CMakeLists.txt, core/libs/prx/libSceLibcInternal/include/Api.hpp, docs/dev/debt/libSceLibcInternal.md
    pr_overlap: cannot confirm overlap with PR 14936: core/libs/prx/libSceLibcInternal/CMakeLists.txt, 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. 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 30 NIDs, the 30 mangled names and TypeInfoDestructors. None of them has a hit:

    PR Title Hits
    #5021 feat(aot): consolidate native ARM64 compiler, runtime and consumers 0
    #13486 fix(relinker): match AppContent utility import to provider 0
    #13778 feat(libSceLibcInternal): implement the msun trigonometric kernels 0
    #13782 feat(libSceLibcInternal): implement floating-point word access 0
    #13881 feat(libSceLibcInternal): implement _readdir_unlocked and _seekdir 0
    #14085 docs(debt): correct stale, contradictory and misplaced entries 0
    #14212 docs(debt): separate entries with blank lines and drop derived export totals 0
    #14401 feat(libSceLibcInternal): implement zero-return showmanyc exports 0
    #14837 feat(libSceLibcInternal): implement the placement operator delete and delete[] 0
    #14936 feat(libSceLibcInternal): implement std::_MP_Add, _MP_Get, _MP_Mul and _MP_Rem 0

    None of them implements these functions or edits the stub lines this PR removes; whichever merges second may need a rebase around the shared CMakeLists.txt, include/Api.hpp and debt-file context.

  • No title was run.

Independent test evidence

  • Independent Windows check on bccff50560: guest_libc_internal_type_info_destructors passed 3/3 under WinLibs GCC 15.2 UCRT. Hosted Windows PR CI does not run this fixture.

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:5150627702 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15695). Originally posted by [B-Howell](https://github.com/B-Howell) on 2026-11-04T07:30:06Z. --- ### What Implements the base-object (`D2`), complete-object (`D1`) and deleting (`D0`) destructors of all ten `__cxxabiv1` RTTI classes in `libSceLibcInternal`. On `main` these were 30 parameterless `sceLibcInternalUnknown_*` stubs in `InventoryExports2.cpp` that threw through `NotImplemented_nid_no_patch`: | Class | `D2` | `D1` | `D0` | |---|---|---|---| | `__fundamental_type_info` | `0jk9oqKd2Gw` | `kzWL2iOsv0E` | `YsZuwZrJZlU` | | `__array_type_info` | `ckFrsyD2830` | `1ZMchlkvNNQ` | `R5nRbLQT3oI` | | `__function_type_info` | `NtqD4Q0vUUI` | `dsQ5Xwhl9no` | `kVvGL9aF5gg` | | `__enum_type_info` | `iQiT26+ZGnA` | `upwSZWmYwqE` | `CjzjU2nFUWw` | | `__class_type_info` | `xXM1q-ayw2Y` | `goLVqD-eiIY` | `XAk7W3NcpTY` | | `__si_class_type_info` | `bWHwovVFfqc` | `6aEkwkEOGRg` | `Fg4w+h9wAMA` | | `__vmi_class_type_info` | `yYIymfQGl2E` | `h-a7+0UuK7Q` | `W5k0jlyBpgM` | | `__pbase_type_info` | `krshE4JAE6M` | `vIJPARS8imE` | `GLxD5v2uMHw` | | `__pointer_type_info` | `vCLVhOcdQMY` | `bhfgrK+MZdk` | `64180GwMVro` | | `__pointer_to_member_type_info` | `Re3Lpk8mwEo` | `KaZ3xf5c9Vc` | `NdeDffcZ-30` | The mangled names are `_ZN10__cxxabiv1<N><class>D<k>Ev`, for example `_ZN10__cxxabiv117__array_type_infoD0Ev`; the NIDs are the ones `docs/dev/debt/libSceLibcInternal.md` listed for those names on `main`. Each export takes `this` as its only argument (`void(void* self)`). Where the behaviour comes from, for every class: - The [Itanium C++ ABI](https://itanium-cxx-abi.github.io/cxx-abi/abi.html#rtti) defines these ten classes with virtual destructors. Its [definitions](https://itanium-cxx-abi.github.io/cxx-abi/abi.html#definitions) make the deleting destructor the complete-object destructor followed by the class's deallocation function, which for these classes is the global `operator delete`. - LLVM libc++abi gives all ten destructors empty bodies: [`private_typeinfo.cpp` L330-L386 at `llvmorg-18.1.8`](https://github.com/llvm/llvm-project/blob/llvmorg-18.1.8/libcxxabi/src/private_typeinfo.cpp#L330-L386), from `__fundamental_type_info::~__fundamental_type_info()` (L330) to `__pointer_to_member_type_info::~__pointer_to_member_type_info()` (L384), each followed by an empty `{` `}`. None of the classes owns anything. - `libc` already treats in-place destruction of guest RTTI as a no-op: the destroy slot of every `libc` RTTI vtable is `LibcException::DestroyTypeInfo` (`core/libs/prx/libc/src/exception/TypeInfo.cpp`), whose body is empty. It is in an anonymous namespace there, so these exports do not call it; they do the same nothing. So `D1` and `D2` leave the object as it is, and `D0` then frees it through `libc`'s `operator delete(void*)` (`_ZdlPv_nid_postfix`, declared in `core/libs/prx/libc/include/Api.hpp`). All 30 exports are in one new file, `TypeInfoDestructors.cpp`, and go through one helper, `RunTypeInfoDestructor(self, deleting)`. They are declared once in `include/Api.hpp`. `libc`'s own `DeleteTypeInfo` throws "deleting guest RTTI is not supported", because the only objects with that vtable are `libc`'s static records. These exports do not copy that throw. That difference, and the fact that the console's `libSceLibcInternal.sprx` was not read (so whether its `D0` frees from the same heap as `libc.prx`, or calls the sized `operator delete`, is unverified), are recorded in one new entry in `docs/dev/debt/libSceLibcInternal.md`. The 30 names leave the "Additional 3.20 imports" stub lists there. This PR replaces four local branches (`feat/lci-typeinfo-a` to `-d`, never opened) that created the same files and edited the same lines. `tools/progress.py` `collect_libraries()`, `origin/main` `5b1d381d5a` against this branch: `libSceLibcInternal` done 92 -> 122 (+30), todo 1045 -> 1015 (-30). The repository total goes from 9913 to 9943 done of 37146 (26.69% -> 26.77%), so +30 done and no new todo. ### 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_type_info_destructors` (`core/libs/tests/GuestLibcInternalTypeInfoDestructors.cpp`). It registers a counting application heap and checks all ten classes with a record of each class's ABI size (16 bytes for the five classes with only `vtable` and `name`, 24 for `__si_class_type_info`, 56 for a two-base `__vmi_class_type_info`, 32 for `__pbase_type_info` and `__pointer_type_info`, 40 for `__pointer_to_member_type_info`): - `D2` and `D1` are each called twice on the record. Its bytes must not change and nothing may be released. - `D0` is called on a record from `libc` `operator new` (`_Znwm`). Exactly that pointer must be released, once, through the heap's free. - `D0` on a null pointer must release nothing, as `operator delete` of null does. - Windows 11, WinLibs GCC 15.2.0, Release, commit `bccff50560`: `guest_libc_internal_type_info_destructors`, `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). - Negative control on Windows: `main`'s `InventoryExports2.cpp` was put back, `TypeInfoDestructors.cpp` was emptied and the new test was kept. The test target fails to link with `undefined reference` to all 30 `sceLibcInternal*TypeInfo*Destructor_nid_no_patch` symbols. - `MSYS_NO_PATHCONV=1 python3 tools/check_conventions.py --base origin/main` with this title and body printed "All conventions checks passed." - `python3 tools/pr_overlap.py --branch feat/lci-typeinfo-destructors` probed 1804 open PRs. No open PR has the same exports or the same new files. Its table lists PRs that edit neighbouring lines only: #14373 and #14834 (`include/Api.hpp` L123 and the debt file L534) and #15692 (`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/include/Api.hpp, docs/dev/debt/libSceLibcInternal.md pr_overlap: cannot confirm overlap with PR 13778: core/libs/prx/libSceLibcInternal/CMakeLists.txt, core/libs/prx/libSceLibcInternal/include/Api.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/include/Api.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, docs/dev/debt/libSceLibcInternal.md pr_overlap: cannot confirm overlap with PR 14837: core/libs/prx/libSceLibcInternal/CMakeLists.txt, core/libs/prx/libSceLibcInternal/include/Api.hpp, docs/dev/debt/libSceLibcInternal.md pr_overlap: cannot confirm overlap with PR 14936: core/libs/prx/libSceLibcInternal/CMakeLists.txt, 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. 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 30 NIDs, the 30 mangled names and `TypeInfoDestructors`. None of them has a hit: | PR | Title | Hits | |---|---|---| | #5021 | feat(aot): consolidate native ARM64 compiler, runtime and consumers | 0 | | #13486 | fix(relinker): match AppContent utility import to provider | 0 | | #13778 | feat(libSceLibcInternal): implement the msun trigonometric kernels | 0 | | #13782 | feat(libSceLibcInternal): implement floating-point word access | 0 | | #13881 | feat(libSceLibcInternal): implement _readdir_unlocked and _seekdir | 0 | | #14085 | docs(debt): correct stale, contradictory and misplaced entries | 0 | | #14212 | docs(debt): separate entries with blank lines and drop derived export totals | 0 | | #14401 | feat(libSceLibcInternal): implement zero-return showmanyc exports | 0 | | #14837 | feat(libSceLibcInternal): implement the placement operator delete and delete[] | 0 | | #14936 | feat(libSceLibcInternal): implement std::_MP_Add, _MP_Get, _MP_Mul and _MP_Rem | 0 | None of them implements these functions or edits the stub lines this PR removes; whichever merges second may need a rebase around the shared `CMakeLists.txt`, `include/Api.hpp` and debt-file context. - No title was run. #### Independent test evidence - [Independent Windows check](https://github.com/boykopovar/AnyPS5/pull/15695#issuecomment-6625761306) on `bccff50560`: `guest_libc_internal_type_info_destructors` passed 3/3 under WinLibs GCC 15.2 UCRT. Hosted Windows PR CI does not run this fixture. ### 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!15695
No description provided.