feat(libc): export std::_Throw_bad_any_cast and std::_Throw_bad_node_access #15791
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/15791"
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 Danigamer05 on 2026-11-04T14:55:47Z.
What
Export the unversioned
std::_Throw_bad_any_cast(const char*)andstd::_Throw_bad_node_access(const char*)from libc._ZSt19_Throw_bad_any_castPKcZEVt6wNNgBk0x819A0_ZSt22_Throw_bad_node_accessPKc4MFvBhXqkmE0xC39A0The behavior comes from the
libc.prxbundled with PPSA03671 v01.001.005 (J03848509, SHA-256483961e086b8a1fffa8138b3c0badf798987fb5f35ec908d828946408be2d8a6).In the module each one copies the message into a new exception and throws it:
_Throw_bad_any_castthrowsSt12bad_any_cast, derived fromSt8bad_cast;_Throw_bad_node_accessthrowsSt16_Bad_node_access, derived fromSt11logic_error;what()slots return the copied message.The module exports neither type, only the throwers, so the two type records and vtables stay internal to
StandardExceptions.cpp, next to the other unversioned throwers. Each one is thrown withThrowMessage, as_Xlength_errorand_Xout_of_rangeare, so it carries this libc's 16-byte message exception. The module's object is 0x30 bytes and holds astd::string. The debt entry records that layout difference and the null message, which is read as empty text here and dereferenced by the module.#15552 adds the versioned
std::__sce_v2::_Throw(const bad_any_cast&), a different export with a different type; this change does not depend on it.Tested
Windows x86-64, WinLibs GCC 15.2.0, Release,
BUILD_TESTING=ON, mainb11c7bf84f5. Exact tested commit:00d87368d9d.Built libc, libkernel, their NID-patched production libraries and the related tests. The new
guest_bad_any_cast_node_accesspasses, along withguest_sce_v2_exceptions,guest_filesystem_error,guest_bad_optional_access,exception_personality,windows_exceptions,guest_libc_internal_exception_destructorsandpublic_headers.The new test throws each export through the assembly catch frame of
GuestSceV2Exceptions.Sand checks the landing selector, the caught type name, its base name andwhat():bad_any_castis caught asstd::bad_cast, asstd::exceptionand by its own name, and not asstd::logic_error,std::runtime_erroror_Bad_node_access;_Bad_node_accessis caught asstd::logic_error, asstd::exceptionand by its own name, and not asstd::runtime_errororstd::bad_cast;what(), and both keep their own copy of a message whose source is overwritten before the catch reads it.The type names, base classes and
what()slots were read from the module's typeinfo, vtables and throwers. The throwers were not run side by side: they end in__cxa_throw, which a host harness cannot catch for the module's frames.Negative control: four lines were altered one at a time:
bad_any_castderived fromlogic_error;_Bad_node_accessderived fromruntime_error;bad_any_castreturned its type name fromwhat();_Throw_bad_node_accessthrew thebad_any_casttable.The new CTest failed on each. The source was then restored byte for byte (SHA-256 checked) and rebuilt, and the test passed again.
Code conventions and
git diff --checkpass.tools/pr_overlap.pyread 1,859 open PRs at the tested commit and reports no overlap. It keeps exit 2 for 35 branches that already conflict with main. None of them adds a line naming these exports or types. Merging each of the 35 with this branch and with main usinggit merge-treegives the same conflict blocks. The branch also merges cleanly with #15336, #15471, #15484, #15490, #15501, #15519, #15552, #15561, #15602, #15614, #15667 and #15683.Not tested: Linux, macOS, another SDK, a game, GPU or console. No game compatibility claim. No original module, extracted bytes, harness or log is committed or uploaded.
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