Repository navigation
fix(libc): let a title's own libunwind read _Unwind_Backtrace frames - #4945
Merged
adriadam10 merged 1 commit intoOct 13, 2026
Merged
Conversation
Homebrew built with the ps5-payload-dev SDK links LLVM libunwind statically but imports _Unwind_Backtrace from libSceLibcInternal. Its trace callback then reads each frame with its own _Unwind_GetIP, which treats the context as a libunwind cursor and calls through the virtual table in its first word. AnyPS5's context started with the saved RAX, so the call jumped to a register value and the title crashed on its error path (vkQuake, PPSA99010, without its game data). The context now starts with a table in AbstractUnwindCursor's slot order that answers register reads and writes, validFloatReg and isSignalFrame; other slots throw. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EvDbpwUPTa78oCAJqe7m9K
Progress report (ea2bbef → db3ec02)📉 System libraries: 87.92% (-0.06%, +3 implemented, +3 declared functions) ✅ 3 implemented
⚪ 1 behaviourally empty (constant return or throw)
🆕 3 declared as stubs
|
10 tasks done
Collaborator
|
Checked on the PR merged onto main: |
10 tasks done
This was referenced Oct 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Homebrew built with the ps5-payload-dev SDK links LLVM libunwind statically, but imports
_Unwind_Backtrace(s62MgBhosjU) fromlibSceLibcInternal. Its trace callback then reads each frame with its own_Unwind_GetIP, i.e.__unw_get_reg(cursor, UNW_REG_IP, &ip), which treats the context as a libunwind cursor:co->validReg(regNum)thenco->getReg(regNum), through the virtual table in the cursor's first word (slots+0x10and+0x18).AnyPS5's
_Unwind_Contextstarts with the saved RAX, so that call jumps to a register value. vkQuake (PPSA99010) without its game data crashes this way on Linux instead of showing its error:(at
app.elf+0x367e, inside the title's own libunwind; the format string next to it islibunwind: __unw_get_reg(cursor=%p, regNum=%d, &value=%p).)The context now starts with a table in LLVM libunwind's
AbstractUnwindCursorslot order (UnwindCursor.hpp: two destructors,validReg,getReg,setReg,validFloatReg,getFloatReg,setFloatReg,step,getInfo,jumpto,isSignalFrame,getFunctionName,setInfoBasedOnIPRegister,getRegisterName). It answers register reads and writes (DWARF numbers 0 to 16,UNW_REG_IP= -1,UNW_REG_SP= -2),validFloatReg(false, as libunwind'sRegisters_x86_64) andisSignalFrame. The other slots throwNotImplemented. AnyPS5's own_Unwind_*functions are unchanged; the register capture and restore code addresses the context throughregisters, so moving it by one word does not affect it.13 of the catalog's titles have both the static libunwind and the
_Unwind_Backtraceimport: PPSA59322, PPSA76677, PPSA85300, PPSA97358, PPSA97510, PPSA98510, PPSA99002, PPSA99010, PPSA99141, PPSA99303, PPSA99309, PPSA99310, PPSA99810.Tested
Linux (Arch, GCC 16.2.1, Release), on
main7e181fc:exception_runtime: a second_Unwind_Backtracecheck reads every frame through the table the way a title's libunwind does (validReg,getRegof IP, SP and RBX,setReg,validFloatReg,isSignalFrame) and compares with_Unwind_GetIPand_Unwind_GetGR. TheRegisterContextlayout assertion now checkscfarelative toregisters.ctest: 1011 of 1011 pass (the display-only VideoOut and AGC tests skip).--to-intel) withoutid1: onmainit dies with SIGSEGV (exit 139). With this change it exits 0 after its own error, as on a console:Quake Error: W_LoadWadFile: couldn't load gfx.wad ... Check that this has an id1 subdirectory containing pak0.pak and pak1.pak.tools/check_conventions.py --base upstream/mainpasses.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)