feat(libc): throw bad_optional_access like bad_weak_ptr #6079
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6079"
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 notaxeltv on 2026-10-14T21:27:13Z.
What
tools/import_audit.pyon PPSA34015 lists absentlibc.prximportKwzEip7m6TM(_ZSt26_Throw_bad_optional_accessv). The type, vtable and_Throwhelper now followbad_weak_ptr: plain exception,what()returnsbad optional access.Tested
Windows 10, WinLibs GCC 15.2.0,
guest_bad_optional_accesspasses.tools/check_conventions.py --base upstream/mainpasses.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)Made with Cursor
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-14T21:27:54Z.
Progress report (
4808d9c→ec03143)📈 System libraries: 88.71% (+0.02%, +7 implemented functions)
✅ 7 implemented
_ZNKSt19bad_optional_access4whatEv_nid_postfix_ZNSt19bad_optional_accessC1Ev_nid_postfix_ZNSt19bad_optional_accessC2Ev_nid_postfix_ZNSt19bad_optional_accessD0Ev_nid_postfix_ZNSt19bad_optional_accessD1Ev_nid_postfix_ZNSt19bad_optional_accessD2Ev_nid_postfix_ZSt26_Throw_bad_optional_accessv_nid_postfixImported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T12:14:19Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)_ZNKSt19bad_optional_access4whatEv_nid_postfix_ZNSt19bad_optional_accessC1Ev_nid_postfix_ZNSt19bad_optional_accessC2Ev_nid_postfix_ZNSt19bad_optional_accessD0Ev_nid_postfix_ZNSt19bad_optional_accessD1Ev_nid_postfix_ZNSt19bad_optional_accessD2Ev_nid_postfix_ZSt26_Throw_bad_optional_accessv_nid_postfixcore/libs/tests/GuestBadOptionalAccess.cppSome comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
core/libs/prx/libc/CMakeLists.txtcore/libs/prx/libc/CMakeLists.txtcore/libs/prx/libc/CMakeLists.txtcore/libs/prx/libc/CMakeLists.txtcore/libs/prx/libc/CMakeLists.txtcore/libs/prx/libc/CMakeLists.txtcore/libs/prx/libc/CMakeLists.txtcore/libs/prx/libc/CMakeLists.txtcore/libs/prx/libc/CMakeLists.txtcore/libs/prx/libc/CMakeLists.txtcore/libs/prx/libc/CMakeLists.txtcore/libs/prx/libc/CMakeLists.txtcore/libs/prx/libc/CMakeLists.txtcore/libs/prx/libc/CMakeLists.txtcore/libs/prx/libc/CMakeLists.txtcore/libs/prx/libc/CMakeLists.txtcore/libs/prx/libc/CMakeLists.txtcore/libs/prx/libc/CMakeLists.txtcore/libs/prx/libc/CMakeLists.txtcore/libs/prx/libc/src/exception/StandardExceptions.cppcore/libs/tests/GuestBadOptionalAccess.cppcore/libs/prx/libc/CMakeLists.txtcore/libs/prx/libc/CMakeLists.txtImported from boykopovar/AnyPS5. Originally posted by coltken95 on 2026-10-15T21:24:36Z.
Tested on Linux x86-64 (Release build), with
ec031436bmerged into maine16b2bcce:guest_bad_optional_accesspasses.std::bad_optional_accessconstructor, destructor, typeinfo andstd::_Throw_bad_optional_accessexports.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by isnisk on 2026-10-16T00:13:56Z.
Checked on Linux: Ubuntu 26.04 (WSL2), GCC 15.2.0, Release, this head (
ec031436b) merged ontomain489466d3f(clean merge).guest_bad_optional_accesspasses, 3 rounds; no compiler warnings. So on Linux the exception is thrown inside libc and caught in the test.main'sStandardExceptions.cpp): the test does not link (undefined reference to _ZTISt19bad_optional_access_nid_postfix,_ZTVSt19bad_optional_access_nid_postfix,_ZNSt19bad_optional_accessC1Ev_nid_postfix).check_conventions.py --base origin/mainpasses.Not checked: macOS, the title.
AI-assisted: yes (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-16T22:14:47Z.
Review: CHANGES_REQUESTED
Thanks for the PR; the vtable/typeinfo/throw plumbing mirrors
bad_weak_ptrcorrectly,guest_bad_optional_accesspasses here, and without the change it fails to link as expected.One point to fix:
core/libs/prx/libc/src/exception/StandardExceptions.cpp:95:what()returns"bad optional access"(the libstdc++/MSVC text). The other plain exceptions in this file follow libc++ ("bad_weak_ptr","std::bad_function_call","std::bad_array_new_length"), and libc++'sbad_optional_access::what()returns"bad_optional_access". Please cite where the string comes from for the PS5 libc (disassembly of alibc.prxthat has the symbol, or another source). If it can't be verified, use the libc++ text and add a line under "Unknown function info" in the libc technical debt file saying the string is unverified. The test atGuestBadOptionalAccess.cpp:30then pins that value.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-19T18:21:59Z.
Thanks @notaxeltv. Closing this as covered by #7872, which has merged with your exports and
guest_bad_optional_accesstest plus thewhat()text and debt note that @adriadam10 asked for in review. Your work is what landed, and the credit is on #7872.Pull request closed