Repository navigation
fix(libkernel): report guest modules' unwind tables on Linux in sceKernelGetModuleInfoForUnwind - #2401
Closed
hugodearaujo wants to merge 1 commit into
Closed
fix(libkernel): report guest modules' unwind tables on Linux in sceKernelGetModuleInfoForUnwind#2401hugodearaujo wants to merge 1 commit into
hugodearaujo wants to merge 1 commit into
Conversation
…rnelGetModuleInfoForUnwind Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
9 tasks done
|
Thank you for your interest in the project! We are sorry, but we cannot accept more PRs while we work through the existing backlog. This PR has been automatically closed and labeled "intake paused". This is not a judgment of the quality of your changes. |
Contributor
Author
|
Closed by the intake check. The diagnosis, the PS5 measurements and this commit are in #2419, so whoever can carry the fix can pick it up from there. |
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
On Linux,
sceKernelGetModuleInfoForUnwindread/proc/self/mapsand always returnedeh_frame_hdr_addr,eh_frame_addrandeh_frame_sizeas 0. A title that ships its ownlibc.prxunwinds with the console's unwinder, which asks this function for each frame's tables. With no tables it finds no handler, so every C++ exception thrown in guest code terminated the title, even ones the title catches.dl_iterate_phdr, as the macOS branch already does. For a guest module (the main program or a*.guest.prx) with aPT_GNU_EH_FRAME, it reports that header, theeh_frameit points to, and the size of the records.seg0is the module's firstPT_LOAD. Host libraries still get no tables, as on Windows.eh_frame_hdrparsing and the record walk move out of the Windows-only block into one helper.eh_frame_sizenow includes the 4-byte zero terminator, as the console reports it (see below). This changes the Windows expectation inGuestUnwindModuleInfo.cppfrom4 + 12to4 + 12 + 4.flagsandname.Measured on a PS5 (firmware 13.60)
A payload calls
sceKernelGetModuleInfoForUnwindfor addresses inlibkernelandlibSceLibcInternaland checks each field independently: it decodes the returned header, compares itseh_framepointer, and walks the records to the terminator.st_sizeeh_frame_hdr_addreh_frame_addreh_frame_ptreh_frame_sizeseg0nameFlags 0, 3 and 8 return
0x80020016, and flags 2 returns0x80020003. An address outside every module (or in the payload, which is not a module) returns0x80020003. Every failure zeroes the whole structure. The flags andnamedifferences stay in TechnicalDebt; this PR does not change them.Evidence: Hollow Knight: Silksong (PPSA12544) on Linux
After a new game's opening video, the title stops:
The exception is
System.Reflection.AmbiguousMatchException, thrown on this path:I read the class from the exception object, and the name from a breakpoint on
RuntimeType.GetMethodImplCommon.HeroControllerhas two overloads with that name, so the exception is expected. The LSDA ofCallMethodProper.PreCachein the title'sIl2cppUserAssemblies.prxhas a catch clause over that call (call site0x123+0xd, landing pad0x1e1, action 3), so on the console it is caught. The title's bundledlibc.prximportssceKernelGetModuleInfoForUnwind, and with no tables it never reached that handler.With this change, the title gets past the opening and into gameplay. Someone played it with a controller for several minutes, including dying and respawning, without an exception reaching
terminate. That run used an earlier revision of this commit, which differed only in leaving the terminator out ofeh_frame_size.Base for these runs:
main+ #1836 + #1431 + #846 + #2323 + #861. They are needed to reach the opening, not for this change.Tested
ctest514/514.guest_unwind_module_infonow has a Linux version, which compares every field againstdl_iterate_phdrand its own header decode and record walk. It covers the main program, a module loaded as*.guest.prx, a host library (no tables,seg0still set) and an unmapped address (ESRCH). It aborts withmain'sModule.cpp.guest_unwind_module_infowith the terminator counted.Module.cpp(sceKernelInternalMemoryGetModuleSegmentInfo). The two conflict on text near the includes, not in the same function.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code