Repository navigation
feat(libc): implement std::_Throw_bad_optional_access - #7872
oneandonlydean merged 2 commits into
Conversation
PPSA26578 (issue boykopovar#7624) imports _ZSt26_Throw_bad_optional_accessv (NID KwzEip7m6TM) from libc, and its bundled libc.prx does not export it, causing the process to exit with 0xC0000139 (GetLastError: 127). Implement std::bad_optional_access type record and vtable deriving from std::exception, thrown through ThrowPlain, with what() returning "bad_optional_access", and add unit test coverage in ExceptionRuntime.
Progress report (d047690 → e775e45)📈 System libraries: 79.77% (+0.03%, +7 implemented functions) ✅ 7 implemented
|
|
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.
Some 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.
|
fogydes
left a comment
There was a problem hiding this comment.
Verified the implementation and test in PR #7872:
- Implementation:
_ZSt26_Throw_bad_optional_accessv_nid_postfixfollows the exact pattern of neighboring exceptions (_throw_bad_variant_access,_Throw_bad_weak_ptr), properly establishing type info and throwing viaThrowPlainwithwhat()returning"bad_optional_access". - Unit Test:
core/libs/tests/ExceptionRuntime.cppverifies that calling the export throws an exception caught asstd::bad_optional_accesswith the expectedwhat()string. - Technical Debt:
docs/dev/debt/libc.mdupdated cleanly. - Conventions: No code comments added; code conventions check passed.
The CI conventions workflow is currently failing because the pull request description does not include the required template sections from .github/pull_request_template.md. Updating the PR body with ### Tested and ### Checklist will clear this check:
### What
PPSA26578 (issue #7624) imports `_ZSt26_Throw_bad_optional_accessv` (NID `KwzEip7m6TM`) from `libc`, and its bundled `libc.prx` does not export it, causing the process to exit at start-up on `main` with:
```text
0xC0000139 (GetLastError: 127)
unresolved ELF import KwzEip7m6TM from libc.prxThis implements std::_Throw_bad_optional_access following the neighboring bad_variant_access and bad_weak_ptr pattern:
_ZTISt19bad_optional_access_nid_postfixand_ZTVSt19bad_optional_access_nid_postfixtype record and vtable deriving fromstd::exception._ZSt26_Throw_bad_optional_accessv_nid_postfix()throwing throughThrowPlain.what()returning"bad_optional_access", matching Dinkumware / libc++ conventions.- Unit test coverage in
ExceptionRuntime.cppverifying the exception is caught asstd::bad_optional_access.
Fixes part of #7624.
Tested
Windows 11, MinGW-w64 GCC 15.2.0 (Release). Verified build and test in ExceptionRuntime.cpp.
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
.mdfiles 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: PPSA26578 #7624
- GPUs tested: n/a
- AI-assisted: no
*(If AI assistance was used, adjust `AI-assisted` to `yes`)*.
|
Heads-up: open PR #6079 already adds the same |
|
Thanks for the review and heads-up @MarcZX10! Regarding the Also updated the PR description with the required |
|
Thanks for explaining the libc++ string choice and updating the PR description. One remaining accuracy point: the new technical-debt entry says The overlap with #6079 also remains: both PRs define |
|
Thanks @MarcZX10!
|
|
Thanks @ErenYeager1836. Merging this one: it carries the |
What
Implements
std::_Throw_bad_optional_access(_ZSt26_Throw_bad_optional_accessv, NIDKwzEip7m6TM) and thestd::bad_optional_accessexception class plumbing incore/libs/prx/libc/src/exception/StandardExceptions.cpp:bad_optional_accesstypeinfo, vtable, constructors (_ZNSt19bad_optional_accessC1Ev,C2Ev), destructors (D1Ev,D2Ev,D0Ev), andwhat()returning"bad_optional_access"(matching Dinkumware and libc++ conventions)._ZTISt19bad_optional_access_nid_postfixand_ZTSSt19bad_optional_access_nid_postfix.KwzEip7m6TMfor PPSA26578 (Unity/IL2CPP) and PPSA34015 (EA SPORTS FC 27).docs/dev/debt/libc.mdwith explicit note that the console libc.prx string is unverified.Tested
guest_bad_optional_accessunit test passes locally with CTest (100% tests passed out of 1).ExceptionRuntimecatch coverage tests throwing and catching byconst std::bad_optional_access&.python tools/check_conventions.py --base upstream/mainpasses 100%.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)