feat(libc): implement std::__throw_bad_variant_access #7506

Merged
cadenasynyster merged 1 commit from upstream-pr/7506 into main 2026-10-19 10:54:49 +00:00
cadenasynyster commented 2026-10-18 10:06:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by cadenasynyster on 2026-10-18T10:06:02Z.


What

Onimusha: Way of the Sword (PPSA27836 01.000.001) imports _ZSt26__throw_bad_variant_accessv (NID 9G6z-nF6njg) from libc. The title's bundled libc.prx does not export it and neither does ours, so on main it stops about 4 s after launch with:

FAIL: unresolved ELF import 9G6z-nF6njg from libc.prx

This adds std::__throw_bad_variant_access next to _Throw_bad_weak_ptr: a std::bad_variant_access type record and vtable deriving from std::exception, thrown through ThrowPlain. what() returns bad_variant_access, the string LLVM libc++ uses (the export carries libc++'s __throw_bad_variant_access name); the console's string is unverified and recorded in docs/dev/debt/libc.md. ExceptionRuntime.cpp checks it the same way as bad_weak_ptr: the call throws, a host catch (const std::bad_variant_access&) catches it, and what() matches.

Only this one export is missing for the title. tools/import_audit.py without --modules also lists wcsncpy_s (Slmz4HMpNGs), wcsncat (pA9N3VIgEZ4) and num_put<char>::_Getcat (hNAh1l09UpA), but the title's own libc.prx contains those three NIDs and only 9G6z-nF6njg is absent from it; the loader resolves the bundled module first. (#6144 adds the two wide-string functions for other titles.)

Tested

Windows 11 10.0.26200.9711, WinLibs GCC 15.2.0 r7, Release, RTX 5070 Ti (NVIDIA 617.42). This commit on main b51c65dd1, dump PPSA27836 01.000.001, relinked with --windows, APS5_PLAYGO_UNLISTED_CHUNKS=installed (the dump has no PlayGo metadata).

  • main: stops at the unresolved import above, about 4 s after launch, every run.
  • With this PR: no unresolved import; the title loads, shows its title screen and menus, and reaches New Game and the first story-mode load. Two runs: one ended after 222 s at that load with AGC graphics: vkQueueSubmit graphics: Vulkan result -4 (the device loss in #6374); the other exited with 0xC0000005 after 186 s, and that log was overwritten before I read it. In earlier runs on the same main with this function plus local copies of the other three, the same load ended once at the #6362 refusal and once at the #6374 device loss (read invalid at 0x5af5000).
  • python tools/check_conventions.py --base origin/main passes.
  • Not run: the ExceptionRuntime test (it includes <sys/wait.h>, so not built in my Windows/MinGW tree); Linux; macOS.

Checklist

  • Based on current main; no other open PR implements the same functions. Overlaps, each in adjacent lines where both sides stay: StandardExceptions.cpp with #6079 (bad_optional_access, the same pattern next to bad_weak_ptr); docs/dev/debt/libc.md with #7386 (the neighbouring entry).
  • 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: PPSA27836 #5595
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4908185115 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7506). Originally posted by [cadenasynyster](https://github.com/cadenasynyster) on 2026-10-18T10:06:02Z. --- ### What Onimusha: Way of the Sword (PPSA27836 01.000.001) imports `_ZSt26__throw_bad_variant_accessv` (NID `9G6z-nF6njg`) from `libc`. The title's bundled `libc.prx` does not export it and neither does ours, so on main it stops about 4 s after launch with: ``` FAIL: unresolved ELF import 9G6z-nF6njg from libc.prx ``` This adds `std::__throw_bad_variant_access` next to `_Throw_bad_weak_ptr`: a `std::bad_variant_access` type record and vtable deriving from `std::exception`, thrown through `ThrowPlain`. `what()` returns `bad_variant_access`, the string LLVM libc++ uses (the export carries libc++'s `__throw_bad_variant_access` name); the console's string is unverified and recorded in `docs/dev/debt/libc.md`. `ExceptionRuntime.cpp` checks it the same way as `bad_weak_ptr`: the call throws, a host `catch (const std::bad_variant_access&)` catches it, and `what()` matches. Only this one export is missing for the title. `tools/import_audit.py` without `--modules` also lists `wcsncpy_s` (`Slmz4HMpNGs`), `wcsncat` (`pA9N3VIgEZ4`) and `num_put<char>::_Getcat` (`hNAh1l09UpA`), but the title's own `libc.prx` contains those three NIDs and only `9G6z-nF6njg` is absent from it; the loader resolves the bundled module first. (#6144 adds the two wide-string functions for other titles.) ### Tested Windows 11 10.0.26200.9711, WinLibs GCC 15.2.0 r7, Release, RTX 5070 Ti (NVIDIA 617.42). This commit on main b51c65dd1, dump PPSA27836 01.000.001, relinked with `--windows`, `APS5_PLAYGO_UNLISTED_CHUNKS=installed` (the dump has no PlayGo metadata). - main: stops at the unresolved import above, about 4 s after launch, every run. - With this PR: no unresolved import; the title loads, shows its title screen and menus, and reaches New Game and the first story-mode load. Two runs: one ended after 222 s at that load with `AGC graphics: vkQueueSubmit graphics: Vulkan result -4` (the device loss in #6374); the other exited with 0xC0000005 after 186 s, and that log was overwritten before I read it. In earlier runs on the same main with this function plus local copies of the other three, the same load ended once at the #6362 refusal and once at the #6374 device loss (`read invalid at 0x5af5000`). - `python tools/check_conventions.py --base origin/main` passes. - Not run: the `ExceptionRuntime` test (it includes `<sys/wait.h>`, so not built in my Windows/MinGW tree); Linux; macOS. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions. Overlaps, each in adjacent lines where both sides stay: `StandardExceptions.cpp` with #6079 (`bad_optional_access`, the same pattern next to `bad_weak_ptr`); `docs/dev/debt/libc.md` with #7386 (the neighbouring entry). - [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: PPSA27836 #5595 - [x] GPUs tested: n/a - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-18 10:31:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-18T10:31:46Z.


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.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 6079 core/libs/prx/libc/src/exception/StandardExceptions.cpp L94, L335, L470
PR 7386 docs/dev/debt/libc.md L96-97
PR 7525 docs/dev/debt/libc.md L96-97

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.

Pull request Shared files not compared
PR 3987 docs/dev/debt/libc.md
PR 5021 docs/dev/debt/libc.md
PR 5303 docs/dev/debt/libc.md
PR 6044 core/libs/tests/ExceptionRuntime.cpp
PR 6226 docs/dev/debt/libc.md
PR 6469 docs/dev/debt/libc.md
PR 6916 docs/dev/debt/libc.md
PR 6975 docs/dev/debt/libc.md
PR 7039 docs/dev/debt/libc.md
PR 7081 docs/dev/debt/libc.md
PR 7201 core/libs/tests/ExceptionRuntime.cpp
PR 7332 core/libs/tests/ExceptionRuntime.cpp
docs/dev/debt/libc.md
PR 7417 docs/dev/debt/libc.md
PR 7473 docs/dev/debt/libc.md
PR 7715 docs/dev/debt/libc.md
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6248785941 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7506#issuecomment-6248785941). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-18T10:31:46Z. --- <!-- pr-overlap --> 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**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | [PR 6079](https://www.github.com/boykopovar/AnyPS5/pull/6079) | `core/libs/prx/libc/src/exception/StandardExceptions.cpp` [L94](https://github.com/boykopovar/AnyPS5/blob/b7a75819f3efad870a3372eb0e2aba1d0e956657/core/libs/prx/libc/src/exception/StandardExceptions.cpp#L94), [L335](https://github.com/boykopovar/AnyPS5/blob/b7a75819f3efad870a3372eb0e2aba1d0e956657/core/libs/prx/libc/src/exception/StandardExceptions.cpp#L335), [L470](https://github.com/boykopovar/AnyPS5/blob/b7a75819f3efad870a3372eb0e2aba1d0e956657/core/libs/prx/libc/src/exception/StandardExceptions.cpp#L470) | | | | [PR 7386](https://www.github.com/boykopovar/AnyPS5/pull/7386) | `docs/dev/debt/libc.md` [L96-97](https://github.com/boykopovar/AnyPS5/blob/b7a75819f3efad870a3372eb0e2aba1d0e956657/docs/dev/debt/libc.md#L96-L97) | | | | [PR 7525](https://www.github.com/boykopovar/AnyPS5/pull/7525) | `docs/dev/debt/libc.md` [L96-97](https://github.com/boykopovar/AnyPS5/blob/b7a75819f3efad870a3372eb0e2aba1d0e956657/docs/dev/debt/libc.md#L96-L97) | | | 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. | Pull request | Shared files not compared | |---|---| | [PR 3987](https://www.github.com/boykopovar/AnyPS5/pull/3987) | `docs/dev/debt/libc.md` | | [PR 5021](https://www.github.com/boykopovar/AnyPS5/pull/5021) | `docs/dev/debt/libc.md` | | [PR 5303](https://www.github.com/boykopovar/AnyPS5/pull/5303) | `docs/dev/debt/libc.md` | | [PR 6044](https://www.github.com/boykopovar/AnyPS5/pull/6044) | `core/libs/tests/ExceptionRuntime.cpp` | | [PR 6226](https://www.github.com/boykopovar/AnyPS5/pull/6226) | `docs/dev/debt/libc.md` | | [PR 6469](https://www.github.com/boykopovar/AnyPS5/pull/6469) | `docs/dev/debt/libc.md` | | [PR 6916](https://www.github.com/boykopovar/AnyPS5/pull/6916) | `docs/dev/debt/libc.md` | | [PR 6975](https://www.github.com/boykopovar/AnyPS5/pull/6975) | `docs/dev/debt/libc.md` | | [PR 7039](https://www.github.com/boykopovar/AnyPS5/pull/7039) | `docs/dev/debt/libc.md` | | [PR 7081](https://www.github.com/boykopovar/AnyPS5/pull/7081) | `docs/dev/debt/libc.md` | | [PR 7201](https://www.github.com/boykopovar/AnyPS5/pull/7201) | `core/libs/tests/ExceptionRuntime.cpp` | | [PR 7332](https://www.github.com/boykopovar/AnyPS5/pull/7332) | `core/libs/tests/ExceptionRuntime.cpp`<br>`docs/dev/debt/libc.md` | | [PR 7417](https://www.github.com/boykopovar/AnyPS5/pull/7417) | `docs/dev/debt/libc.md` | | [PR 7473](https://www.github.com/boykopovar/AnyPS5/pull/7473) | `docs/dev/debt/libc.md` | | [PR 7715](https://www.github.com/boykopovar/AnyPS5/pull/7715) | `docs/dev/debt/libc.md` |
github-actions[bot] commented 2026-10-18 11:08:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-18T11:08:37Z.


Progress report (9caecfd → 9f3e867)

➖ System libraries: 90.32% (+0.0%, +1 implemented functions)

✅ 1 implemented
Library Name
libc _ZSt26__throw_bad_variant_accessv_nid_postfix
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6249138097 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7506#issuecomment-6249138097). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-18T11:08:37Z. --- <!-- progress-report --> ### Progress report (9caecfd → 9f3e867) ➖ **System libraries**: 90.32% (+0.0%, +1 implemented functions) <details> <summary>✅ 1 implemented</summary> | Library | Name | | - | - | | libc | `_ZSt26__throw_bad_variant_accessv_nid_postfix` | </details>
wachi35676 commented 2026-10-18 12:05:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by wachi35676 on 2026-10-18T12:05:42Z.


Linux results, which the description lists as not run. WSL Ubuntu 24.04 (gcc 13.3), Release, main 3e3e8b905 plus this PR:

  • exception_runtime passes (5/5 with --repeat until-fail:5), and so does exception_personality.
  • With only the test change on main, exception_runtime fails to link: undefined reference to _ZSt26__throw_bad_variant_accessv_nid_postfix.
  • The patched libc.prx exports 9G6z-nF6njg on Linux (nm -D) and on Windows/MinGW GCC 15.2.0 (objdump -p), the same NID nid_names.py gives.

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

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6249706446 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7506#issuecomment-6249706446). Originally posted by [wachi35676](https://github.com/wachi35676) on 2026-10-18T12:05:42Z. --- Linux results, which the description lists as not run. WSL Ubuntu 24.04 (gcc 13.3), Release, `main` `3e3e8b905` plus this PR: - `exception_runtime` passes (5/5 with `--repeat until-fail:5`), and so does `exception_personality`. - With only the test change on `main`, `exception_runtime` fails to link: `undefined reference to _ZSt26__throw_bad_variant_accessv_nid_postfix`. - The patched `libc.prx` exports `9G6z-nF6njg` on Linux (`nm -D`) and on Windows/MinGW GCC 15.2.0 (`objdump -p`), the same NID `nid_names.py` gives. AI-assisted: yes (Claude Code); results above were run on this machine.
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!7506
No description provided.