fix(libkernel): report guest unwind tables in sceKernelGetModuleInfoForUnwind on Linux #1600
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1600"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by awake-devel on 2026-10-08T14:06:29Z.
What
#904 made
sceKernelGetModuleInfoForUnwindreport a guest image's unwind tables on Windows. On Linux the call still answerseh_frame_hdr_addr,eh_frame_addrandeh_frame_size= 0 for every address. A title that ships its ownlibc.prxunwinds C++ exceptions with that libc's libunwind, which asks this call where a frame's FDEs are; with the empty answer it falls back to its list of registered frames, which is empty, so no C++ exception thrown in guest code can be caught on Linux.PPSA12544 (Hollow Knight: Silksong) on Linux ends after its intro cinematic with the same message #904 fixed on Windows:
(reported in https://github.com/boykopovar/AnyPS5/discussions/1519).
On Linux, for an address in the main executable or in a
.guest.prximage, the call now fills the three fields from the image'sPT_GNU_EH_FRAME, assceKernelGetModuleInfoFromAddralready reports them (same header,eh_frame_ptrdecoding and record walk).name,seg0_addrandseg0_sizestill come from/proc/self/mapsas before. Other host images (the emulator's own.prxlibraries, system libraries) still report no tables, as on Windows. Windows and macOS code is unchanged.eh_frame_sizefromsceKernelGetModuleInfoFromAddrincludes the zero terminator, while Windows stops before it. LLVM libunwind'sCFI_Parser::findFDEstops at the terminator or the length, whichever comes first, so both find the same FDEs; the TechnicalDebt entry now says so.The main executable on Linux keeps its
PT_GNU_EH_FRAMEonly with the relinker change in #1586 (keepsPT_GNU_EH_FRAMEin the relinked executable); without it the executable still reports no tables (as today), while.guest.prxmodules already work.guest_unwind_module_infonow also runs on Linux (newGuestUnwindModuleInfoLinux.cpp). It checks that the call returns thePT_GNU_EH_FRAMEheader, the decodedeh_frameaddress and a non-zero size for a function in the test executable and for a function in a fixture loaded asguest_unwind_module_info_fixture.prx.guest.prxthroughdlopen_nid_postfix, and that a function in the host C library and one inlibkernelreport no tables.Tested
Arch Linux (kernel 7.2), GCC, Release,
-DBUILD_TESTING=ON; i7-8750H, GTX 1050 Ti Max-Q (NVIDIA 580.178.04) + Intel UHD 630. Rebased ontomain406b5e1c; the results below are on406b5e1cunless marked as from the earlier basecba8d86d.guest_unwind_module_info: passes; with only theModule.cppchange reverted it fails oncba8d86d(Subprocess aborted: the test executable and the.guest.prxfixture get no tables).ctest -j4: 483/483 passed, 0 skipped, 0 failed (main406b5e1c: 482/482, 0 skipped, 0 failed; the new test is the only difference).VK_LAYER_KHRONOS_validation(ctest -j2 -V, oncba8d86d): 453/453 passed, 0 skipped; the sameValidation ErrorVUIDs and counts asmain(2VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605).tools/check_conventions.py --base 406b5e1candtools/check_test_registration.py build: pass.Terminating due to uncaught exception of type Il2CppExceptionWrapper; with both changes (this commit before the rebase, 56169fb7) the cinematic starts at about t+104 s, the exception is caught, and the game reaches gameplay: the tutorial area loads and a save is written at t+349 s. (The run also used local, unmerged changes needed to boot the title, such as #846 for--module-dir.)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
https://claude.ai/code/session_01HeC9bA3n74TzJRYv9AgBE8
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T09:22:20Z.
Module.cpp:106returns no tables whensceKernelGetModuleInfoFromAddrfails for a relinked image; please throw there, as the Windows path does. The Windows job failure (guest_ampr_markers) doesn't look related to this change.Imported from boykopovar/AnyPS5. Originally posted by popcoder565 on 2026-10-09T15:45:37Z.
Native Windows run, since no Windows results were posted. Setup: Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Head
cfbd3a5c, merged ontomaind70b8998in one build with 38 other PRs that had no Windows run.guest_unwind_module_infopasses.No title was run.
🤖 Addressed by Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T19:02:39Z.
Issue #2419 now includes direct PS5 firmware 13.60 measurements for
sceKernelGetModuleInfoForUnwind, including the exacteh_frameterminator behavior. That evidence is useful for this PR:\n\n- Withflags = 1, the measuredeh_frame_sizeincludes the four-byte zero terminator. The current Linux implementation ofsceKernelGetModuleInfoFromAddrcomputes that same length (EhFrameSizereturns after advancing over the zero record), so copying its result here already includes the terminator. The TechnicalDebt sentence in this PR still says the console behavior is unknown; #2419 settles that point and the wording should be updated.\n- The measured successful result has an emptyname; flags 0, 3, and 8 return0x80020016, flags 2 returns0x80020003, and errors zero the entire output. Those behaviors are useful to keep recorded as known differences where this implementation intentionally still ignoresflagsor reports host metadata.\n- The existing review request atModule.cpp:106remains: if the lookup fails for an image already classified as a guest image, propagate an error instead of returning success with zero unwind tables.\n\nThis is review evidence only; the Linux implementation and focused test in #2419 provide a related patch, but I have not copied or run that separate patch on this PR head.Imported from boykopovar/AnyPS5. Originally posted by jweidenh on 2026-10-09T20:23:51Z.
I prepared a focused follow-up for the outstanding failed-lookup review request: commit 132c3a50 (mail patch). It applies directly to this PR's current head,
cfbd3a5c.The change throws when
sceKernelGetModuleInfoFromAddrreturns an error. It adds a Linux regression using executable symbol interposition, so the error path needs no production test hook. The metadata test now independently bounds and walks the EH records, verifies the exact size including the four-byte terminator, covers a guest DSO without an EH header, and checks host-library suppression. The debt entry attributes the firmware measurements to #2419 and records the remaining ABI differences.Validation on locally managed self-hosted Ubuntu 24.04.5 x86-64 runners, GCC 13.3, Mesa 25.2.8/lavapipe:
8b393b6e'sModule.cpp. Restoring the patch returned both tests to passing.e4c9b885, containing this PR, the follow-up and upstream8b393b6e: full Release build, patched-library build and test-registration check passed. The full suite had 494 passed, 26 skipped and 2 timeouts out of 522; both unwind tests passed in about 3 ms.agc_driver_flat_store(previously reproduced on upstreamd70b8998) andagc_driver_global_vcc_base. The latter also timed out at 30.05 s on clean upstream8b393b6e, alone with a fresh driver cache, without any unwind changes. No tests were excluded or timeouts raised.No title, PS5 hardware or actual relinked guest exception catch was exercised. Windows/macOS behavior and the remaining flags/name/error-zeroing/seg0 differences are outside this follow-up. The single follow-up commit can be cherry-picked independently of the integration merge.
AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T00:19:41Z.
Rebased onto current
main(only a TechnicalDebt adjacency conflict) and added the following as a second commit, so it can land as is:Module.cpp:FillGuestUnwindInfonow throws whensceKernelGetModuleInfoFromAddrfails, as asked by @oneandonlydean. The patch is @jweidenh's from the thread, cherry-picked (credited as co-author).guest_unwind_module_info_failuretest (symbol interposition, no production hook), and the metadata test now walks the EH records and covers a DSO without an EH header.eh_frame_sizeentry now says it includes the terminator on Linux (firmware 13.60 measurement reported in #2419) and that other host images report none.Checked: scoped build + ctest on Linux, both
guest_unwind_module_info*tests pass and both fail withModule.cppreverted tomain. Merging once CI is green.