Skip to content

fix(libc): return the bad_alloc and bad_function_call what() strings of the libc.prx titles ship - #11213

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
AlexFigas:fix/libc-exception-what-strings
Nov 1, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
AlexFigas:fix/libc-exception-what-strings

Conversation

@AlexFigas

@AlexFigas AlexFigas commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

What

std::bad_alloc, std::bad_array_new_length and std::bad_function_call returned std::bad_alloc, std::bad_array_new_length and std::bad_function_call from what(). The libc.prx that PPSA21564 bundles (sce_module/libc.prx, the library's own code) returns bad allocation, bad allocation and bad function call. Every vtable below was resolved through the module's R_X86_64_RELATIVE relocations, read from the disassembly, not measured:

Class what() in that libc.prx Here before
std::bad_alloc bad allocation (_ZNKSt9bad_alloc4whatEv, 0x16fa0) std::bad_alloc
std::bad_array_new_length bad allocation (its vtable points at bad_alloc::what) std::bad_array_new_length
std::bad_function_call bad function call (0x177d0) std::bad_function_call
std::bad_cast, std::bad_typeid std::bad_cast, std::bad_typeid unchanged, same
std::bad_weak_ptr, std::bad_variant_access bad_weak_ptr, bad_variant_access unchanged, same

The library's __sce_v2 bad_function_call already returned bad function call. The _Xbad_alloc case of guest_sce_v2_exceptions and the plain what mode of guest_message_destructor_abi, which expected the old bad_alloc string, now expect bad allocation.

Not changed here:

  • In that libc.prx, std::exception::what (0x17040) returns an empty string. std::bad_exception and std::bad_optional_access don't override it (their vtables point at it), so they return it too.
  • Here, the three return std::exception, St13bad_exception and bad_optional_access.
  • test(libc): cover the standard exception classes and throw helpers #9773 adds a test that requires a non-empty what() for std::exception, so these three are left for a follow-up.
  • The debt entries for bad_variant_access and bad_optional_access are not edited here, because four open PRs change the lines around them.

Tested

Ubuntu 24.04 (WSL2), GCC 13.3, Release build with BUILD_TESTING=ON, head edeac65 on main 1089f2b. That main has the future_error/error_category (#11241) and underflow_error (#10608) exports in StandardExceptions.cpp and the SCE v2 test-overread fix (#10829):

  • guest_sce_v2_exceptions, guest_bad_optional_access and exception_runtime pass 3 runs each, as do exception_personality, exception_c_cleanup, host_libstdcxx_exception and unwind_callback_abi_delete_exception.
  • guest_message_destructor_abi is built only with MinGW, so I did not run it, and the hosted Windows job cannot either: on pull requests it only links the host-only tests, and this one links the guest libc. Its expected string is updated the same way.
  • python3 tools/check_conventions.py --base origin/main passes.
  • python3 tools/pr_overlap.py --branch fix/libc-exception-what-strings finds no overlap. feat(libc): implement std::_Throw(const std::bad_array_new_length&) #10927 adds std::_Throw(const std::bad_array_new_length&), and its test does not check the string.

No title run.

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

@github-actions github-actions Bot added the libc label Oct 26, 2026
@wachi35676

Copy link
Copy Markdown
Contributor

Windows and Linux runs of head e529021b934f merged onto main 14eb2cda22d2. Windows used WinLibs GCC 15.2.0, Linux used WSL with GCC 13; both Release.

  • On Windows the 16 built exception tests pass, including the guest_message_destructor_abi modes and guest_exception_vtable-*. With main's StandardExceptions.cpp, guest_sce_v2_exceptions and guest_exception_vtable-plain-what-decoy fail.
  • On Linux guest_sce_v2_exceptions passes 3/3 and fails with main's file.
  • Nothing else in the tree still expects the old std::bad_alloc / std::bad_function_call strings.

AI-assisted: yes (Claude Code); results above were run on this machine.

@oneandonlydean oneandonlydean self-assigned this Oct 26, 2026

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bundled libc.prx vtable/string evidence is specific, and the changed mapping plus expectation updates are small. I am not approving this submitted head yet because it is based on 88f9967, while current main is 3fea2a9. Since that base, main changed StandardExceptions.cpp and the guest exception tests this PR edits (including the SCE v2 test-overread fix). The current diff therefore has not been checked against the current implementation and fixtures.

Please rebase onto current main, rerun the affected exception tests on that tree, and report the MinGW-only guest_message_destructor_abi result if the Windows check can execute it. I found no independent defect in the small string mapping itself; this request is for current-tree integration and repeatable test evidence under the repository's branch-currency rule.

@AlexFigas
AlexFigas force-pushed the fix/libc-exception-what-strings branch from e529021 to edeac65 Compare October 27, 2026 14:35
@AlexFigas

Copy link
Copy Markdown
Contributor Author

@MarcZX10 Rebased onto main 1089f2b (edeac65), which has the StandardExceptions.cpp changes from #11241 and #10608 and the SCE v2 test-overread fix from #10829. On this head, guest_sce_v2_exceptions, guest_bad_optional_access and exception_runtime pass 3 runs each, as do the other exception tests (exception_personality, exception_c_cleanup, host_libstdcxx_exception, unwind_callback_abi_delete_exception).

guest_message_destructor_abi is MinGW-only, and I have no Windows machine. The hosted Windows check can't run it either: on pull requests it only links the host-only tests, and this test links the guest libc. Its expected string is updated in the same way as the others.

@AlexFigas
AlexFigas requested a review from MarcZX10 October 27, 2026 14:50

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed exact head edeac65600f4bc780320905a47f43b8c5bfb029c against current main 2ee8e9751a06bd4cb7edb8d17f433d56a39a7025.

The three PlainWhat mappings match the strings documented from PPSA21564's bundled libc.prx; bad_array_new_length correctly shares bad_alloc's bad allocation text. The updated guest test expectations match those outputs, while the existing __sce_v2 bad-function-call mapping remains unchanged. I found no issue in the changed paths. The overlap scan reports no open-PR overlap; the current-main merge preview is clean, and none of the intervening main commits changes these three paths.

Local verification: Release build of guest_sce_v2_exceptions_tests, guest_bad_optional_access_tests, and exception_runtime_tests succeeded. Those three CTests passed three repetitions each (9/9). check_conventions.py and git diff --check passed. Hosted Windows, Ubuntu relinker, Ubuntu register-context, ASan relinker, conventions, eligibility, intake, labels, and report checks pass; Linux product is skipped, and macOS jobs remain queued. I could not run the MinGW-only guest_message_destructor_abi on this Linux host; hosted Windows does not build that guest-linked test. No PS5 title run was performed.

@MarcZX10

Copy link
Copy Markdown
Contributor

Follow-up to my review: both previously queued macOS relinker checks have now completed successfully. The hosted checks for this head are green, with the Linux product job skipped by the workflow path filters. The MinGW-only guest_message_destructor_abi test still was not run locally; the existing review records that remaining coverage limit.

@BunnyFl BunnyFl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving head edeac65600. I read the diff and ran firmware 13.42's std::bad_alloc::what (xvRvFtnUk3E) and std::bad_function_call::what (XVu4--EWzcM): the decrypted system libSceLibcInternal.sprx's exports, natively on a PC (not a console). Three identical runs.

They return "bad allocation" and "bad function call", the strings this change uses (the updated tests check the bad allocation one), so the system module agrees with the PPSA21564 libc.prx reading in the description. I did not check bad_array_new_length's vtable or the unchanged classes in the module.

@AlexFigas

Copy link
Copy Markdown
Contributor Author

@MarcZX10 The approved head edeac65 still merges cleanly into current main cc26ab4. main has changed StandardExceptions.cpp and GuestSceV2Exceptions.cpp since, so I built the merge result (ed4265d81b) separately and did not move this branch. On it guest_sce_v2_exceptions, guest_bad_optional_access, exception_runtime, exception_personality, exception_c_cleanup, exception_compact_unwind, host_libstdcxx_exception and the unwind_callback_abi_* tests (12 in all) pass 3 runs each, and git diff --check is clean.

@oneandonlydean
oneandonlydean merged commit 06cf0fb into boykopovar:main Nov 1, 2026
18 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants