feat(libSceLibcInternal): run the C++ ABI type_info destructors #15695
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/15695"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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__cxxabiv1RTTI classes inlibSceLibcInternal. Onmainthese were 30 parameterlesssceLibcInternalUnknown_*stubs inInventoryExports2.cppthat threw throughNotImplemented_nid_no_patch:D2D1D0__fundamental_type_info0jk9oqKd2GwkzWL2iOsv0EYsZuwZrJZlU__array_type_infockFrsyD28301ZMchlkvNNQR5nRbLQT3oI__function_type_infoNtqD4Q0vUUIdsQ5Xwhl9nokVvGL9aF5gg__enum_type_infoiQiT26+ZGnAupwSZWmYwqECjzjU2nFUWw__class_type_infoxXM1q-ayw2YgoLVqD-eiIYXAk7W3NcpTY__si_class_type_infobWHwovVFfqc6aEkwkEOGRgFg4w+h9wAMA__vmi_class_type_infoyYIymfQGl2Eh-a7+0UuK7QW5k0jlyBpgM__pbase_type_infokrshE4JAE6MvIJPARS8imEGLxD5v2uMHw__pointer_type_infovCLVhOcdQMYbhfgrK+MZdk64180GwMVro__pointer_to_member_type_infoRe3Lpk8mwEoKaZ3xf5c9VcNdeDffcZ-30The mangled names are
_ZN10__cxxabiv1<N><class>D<k>Ev, for example_ZN10__cxxabiv117__array_type_infoD0Ev; the NIDs are the onesdocs/dev/debt/libSceLibcInternal.mdlisted for those names onmain. Each export takesthisas its only argument (void(void* self)).Where the behaviour comes from, for every class:
operator delete.private_typeinfo.cppL330-L386 atllvmorg-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.libcalready treats in-place destruction of guest RTTI as a no-op: the destroy slot of everylibcRTTI vtable isLibcException::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
D1andD2leave the object as it is, andD0then frees it throughlibc'soperator delete(void*)(_ZdlPv_nid_postfix, declared incore/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 ininclude/Api.hpp.libc's ownDeleteTypeInfothrows "deleting guest RTTI is not supported", because the only objects with that vtable arelibc's static records. These exports do not copy that throw. That difference, and the fact that the console'slibSceLibcInternal.sprxwas not read (so whether itsD0frees from the same heap aslibc.prx, or calls the sizedoperator delete, is unverified), are recorded in one new entry indocs/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-ato-d, never opened) that created the same files and edited the same lines.tools/progress.pycollect_libraries(),origin/main5b1d381d5aagainst this branch:libSceLibcInternaldone 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 onlyvtableandname, 24 for__si_class_type_info, 56 for a two-base__vmi_class_type_info, 32 for__pbase_type_infoand__pointer_type_info, 40 for__pointer_to_member_type_info):D2andD1are each called twice on the record. Its bytes must not change and nothing may be released.D0is called on a record fromlibcoperator new(_Znwm). Exactly that pointer must be released, once, through the heap's free.D0on a null pointer must release nothing, asoperator deleteof null does.Windows 11, WinLibs GCC 15.2.0, Release, commit
bccff50560:guest_libc_internal_type_info_destructors,guest_libc_internal_exception_destructorsandpublic_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'sInventoryExports2.cppwas put back,TypeInfoDestructors.cppwas emptied and the new test was kept. The test target fails to link withundefined referenceto all 30sceLibcInternal*TypeInfo*Destructor_nid_no_patchsymbols.MSYS_NO_PATHCONV=1 python3 tools/check_conventions.py --base origin/mainwith this title and body printed "All conventions checks passed."python3 tools/pr_overlap.py --branch feat/lci-typeinfo-destructorsprobed 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.hppL123 and the debt file L534) and #15692 (include/Api.hppL123); whichever merges second needs a trivial rebase. It then reported:Manual comparison of those ten PRs. For each I took its diff (
gh pr diff; for #5021, which is too large for that, thelibSceLibcInternalfile patches from the pull request files API) and searched every added and removed line for the 30 NIDs, the 30 mangled names andTypeInfoDestructors. None of them has a hit: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.hppand debt-file context.No title was run.
Independent test evidence
bccff50560:guest_libc_internal_type_info_destructorspassed 3/3 under WinLibs GCC 15.2 UCRT. Hosted Windows PR CI does not run this fixture.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
🤖 Updated with Codex