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

Merged
AlexFigas merged 1 commit from upstream-pr/11213 into main 2026-11-01 21:19:00 +00:00
AlexFigas commented 2026-10-25 21:55:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by AlexFigas on 2026-10-25T21:55:44Z.


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.
  • #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 edeac65600 on main 1089f2bbfd. 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. #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
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5009102145 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11213). Originally posted by [AlexFigas](https://github.com/AlexFigas) on 2026-10-25T21:55:44Z. --- ### 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`. - #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 <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Ubuntu 24.04 (WSL2), GCC 13.3, Release build with `BUILD_TESTING=ON`, head edeac65600 on `main` 1089f2bbfd. 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. #10927 adds `std::_Throw(const std::bad_array_new_length&)`, and its test does not check the string. No title run. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-10-27 11:00:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-27T11:00:04Z.

Review: CHANGES_REQUESTED


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 88f99678bf, while current main is 3fea2a937b. 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.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5665951676 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11213#pullrequestreview-5665951676). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-27T11:00:04Z. **Review:** CHANGES_REQUESTED --- 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 88f99678bff7345c2a7f83aefcf1b2a8a81c7498, while current main is 3fea2a937ba9fbab2f06c51691fe0c5763659aa3. 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.
MarcZX10 commented 2026-10-27 15:03:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-27T15:03:49Z.

Review: APPROVED


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.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5669342783 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11213#pullrequestreview-5669342783). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-27T15:03:49Z. **Review:** APPROVED --- 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.
BunnyFl commented 2026-10-28 15:25:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-10-28T15:25:03Z.

Review: APPROVED


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.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5685184119 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11213#pullrequestreview-5685184119). Originally posted by [BunnyFl](https://github.com/BunnyFl) on 2026-10-28T15:25:03Z. **Review:** APPROVED --- 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.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!11213
No description provided.