Skip to content

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

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
cadenasynyster:fix/libc-throw-bad-variant-access
Oct 19, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
cadenasynyster:fix/libc-throw-bad-variant-access

Conversation

@cadenasynyster

@cadenasynyster cadenasynyster commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

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 b51c65d, dump PPSA27836 01.000.001, relinked with --windows, APS5_PLAYGO_UNLISTED_CHUNKS=installed (the dump has no PlayGo metadata).

Checklist

Onimusha: Way of the Sword (PPSA27836 01.000.001) imports
_ZSt26__throw_bad_variant_accessv (9G6z-nF6njg) from libc, and its
bundled libc.prx does not export it, so the title fails to load with
an unresolved import.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GtXavMkgCTCdmRpweviHcQ
@github-actions

github-actions Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

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

@github-actions

Copy link
Copy Markdown

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

@adriadam10 adriadam10 removed their assignment Oct 18, 2026
@wachi35676

Copy link
Copy Markdown
Contributor

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 up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs libc unblocks title Names a title ID on the Unblocks line

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants