fix(libkernel): report guest unwind tables in sceKernelGetModuleInfoForUnwind on Linux #1600

Merged
awake-devel merged 2 commits from upstream-pr/1600 into main 2026-10-10 01:13:41 +00:00
awake-devel commented 2026-10-08 14:06:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by awake-devel on 2026-10-08T14:06:29Z.


Investigated and written by Claude Code (AI), and posted by me after review.

What

#904 made sceKernelGetModuleInfoForUnwind report a guest image's unwind tables on Windows. On Linux the call still answers eh_frame_hdr_addr, eh_frame_addr and eh_frame_size = 0 for every address. A title that ships its own libc.prx unwinds 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:

Terminating due to uncaught exception of type Il2CppExceptionWrapper

(reported in https://github.com/boykopovar/AnyPS5/discussions/1519).

On Linux, for an address in the main executable or in a .guest.prx image, the call now fills the three fields from the image's PT_GNU_EH_FRAME, as sceKernelGetModuleInfoFromAddr already reports them (same header, eh_frame_ptr decoding and record walk). name, seg0_addr and seg0_size still come from /proc/self/maps as before. Other host images (the emulator's own .prx libraries, system libraries) still report no tables, as on Windows. Windows and macOS code is unchanged.

eh_frame_size from sceKernelGetModuleInfoFromAddr includes the zero terminator, while Windows stops before it. LLVM libunwind's CFI_Parser::findFDE stops 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_FRAME only with the relinker change in #1586 (keeps PT_GNU_EH_FRAME in the relinked executable); without it the executable still reports no tables (as today), while .guest.prx modules already work.

guest_unwind_module_info now also runs on Linux (new GuestUnwindModuleInfoLinux.cpp). It checks that the call returns the PT_GNU_EH_FRAME header, the decoded eh_frame address and a non-zero size for a function in the test executable and for a function in a fixture loaded as guest_unwind_module_info_fixture.prx.guest.prx through dlopen_nid_postfix, and that a function in the host C library and one in libkernel report 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 onto main 406b5e1c; the results below are on 406b5e1c unless marked as from the earlier base cba8d86d.

  • guest_unwind_module_info: passes; with only the Module.cpp change reverted it fails on cba8d86d (Subprocess aborted: the test executable and the .guest.prx fixture get no tables).
  • Full ctest -j4: 483/483 passed, 0 skipped, 0 failed (main 406b5e1c: 482/482, 0 skipped, 0 failed; the new test is the only difference).
  • Full suite under VK_LAYER_KHRONOS_validation (ctest -j2 -V, on cba8d86d): 453/453 passed, 0 skipped; the same Validation Error VUIDs and counts as main (2 VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605).
  • tools/check_conventions.py --base 406b5e1c and tools/check_test_registration.py build: pass.
  • PPSA12544 on Linux, relinked with this change and the relinker change above: before, the run ended at the end of the intro cinematic with 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

  • Based on current main; no other open PR implements the same functions
  • 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 in TechnicalDebt
  • 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 (the main executable's tables need #1586 to reach the call)
  • AI-assisted: yes

🤖 Generated with Claude Code

https://claude.ai/code/session_01HeC9bA3n74TzJRYv9AgBE8

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4788027447 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1600). Originally posted by [awake-devel](https://github.com/awake-devel) on 2026-10-08T14:06:29Z. --- > Investigated and written by Claude Code (AI), and posted by me after review. ### What #904 made `sceKernelGetModuleInfoForUnwind` report a guest image's unwind tables on Windows. On Linux the call still answers `eh_frame_hdr_addr`, `eh_frame_addr` and `eh_frame_size` = 0 for every address. A title that ships its own `libc.prx` unwinds 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: ``` Terminating due to uncaught exception of type Il2CppExceptionWrapper ``` (reported in https://github.com/boykopovar/AnyPS5/discussions/1519). On Linux, for an address in the main executable or in a `.guest.prx` image, the call now fills the three fields from the image's `PT_GNU_EH_FRAME`, as `sceKernelGetModuleInfoFromAddr` already reports them (same header, `eh_frame_ptr` decoding and record walk). `name`, `seg0_addr` and `seg0_size` still come from `/proc/self/maps` as before. Other host images (the emulator's own `.prx` libraries, system libraries) still report no tables, as on Windows. Windows and macOS code is unchanged. `eh_frame_size` from `sceKernelGetModuleInfoFromAddr` includes the zero terminator, while Windows stops before it. LLVM libunwind's `CFI_Parser::findFDE` stops 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_FRAME` only with the relinker change in #1586 (keeps `PT_GNU_EH_FRAME` in the relinked executable); without it the executable still reports no tables (as today), while `.guest.prx` modules already work. `guest_unwind_module_info` now also runs on Linux (new `GuestUnwindModuleInfoLinux.cpp`). It checks that the call returns the `PT_GNU_EH_FRAME` header, the decoded `eh_frame` address and a non-zero size for a function in the test executable and for a function in a fixture loaded as `guest_unwind_module_info_fixture.prx.guest.prx` through `dlopen_nid_postfix`, and that a function in the host C library and one in `libkernel` report 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 onto `main` 406b5e1c; the results below are on 406b5e1c unless marked as from the earlier base cba8d86d. - `guest_unwind_module_info`: passes; with only the `Module.cpp` change reverted it fails on cba8d86d (`Subprocess aborted`: the test executable and the `.guest.prx` fixture get no tables). - Full `ctest -j4`: 483/483 passed, 0 skipped, 0 failed (`main` 406b5e1c: 482/482, 0 skipped, 0 failed; the new test is the only difference). - Full suite under `VK_LAYER_KHRONOS_validation` (`ctest -j2 -V`, on cba8d86d): 453/453 passed, 0 skipped; the same `Validation Error` VUIDs and counts as `main` (2 `VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605`). - `tools/check_conventions.py --base 406b5e1c` and `tools/check_test_registration.py build`: pass. - PPSA12544 on Linux, relinked with this change and the relinker change above: before, the run ended at the end of the intro cinematic with `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 <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [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 in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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 (the main executable's tables need #1586 to reach the call) - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01HeC9bA3n74TzJRYv9AgBE8
oneandonlydean commented 2026-10-09 09:22:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T09:22:20Z.


Module.cpp:106 returns no tables when sceKernelGetModuleInfoFromAddr fails 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.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6078121303 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1600#issuecomment-6078121303). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-09T09:22:20Z. --- `Module.cpp:106` returns no tables when `sceKernelGetModuleInfoFromAddr` fails 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.
popcoder565 commented 2026-10-09 15:45:37 +00:00 (Migrated from github.com)

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 onto main d70b8998 in one build with 38 other PRs that had no Windows run.

  • Its new test is registered only on Linux, so on Windows this only checks that the change builds. The existing Windows guest_unwind_module_info passes.
  • Full ctest in that build: 519 of 519. That needed local fixes to three other PRs in the batch that don't build or pass on Windows: #1611, #1796 and #1824 (reported there).

No title was run.

🤖 Addressed by Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6084258493 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1600#issuecomment-6084258493). Originally posted by [popcoder565](https://github.com/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 onto `main` d70b8998 in one build with 38 other PRs that had no Windows run. - Its new test is registered only on Linux, so on Windows this only checks that the change builds. The existing Windows `guest_unwind_module_info` passes. - Full ctest in that build: 519 of 519. That needed local fixes to three other PRs in the batch that don't build or pass on Windows: #1611, #1796 and #1824 (reported there). No title was run. _🤖 Addressed by [Claude Code](https://claude.com/claude-code)_
MarcZX10 commented 2026-10-09 19:02:39 +00:00 (Migrated from github.com)

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 exact eh_frame terminator behavior. That evidence is useful for this PR:\n\n- With flags = 1, the measured eh_frame_size includes the four-byte zero terminator. The current Linux implementation of sceKernelGetModuleInfoFromAddr computes that same length (EhFrameSize returns 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 empty name; flags 0, 3, and 8 return 0x80020016, flags 2 returns 0x80020003, and errors zero the entire output. Those behaviors are useful to keep recorded as known differences where this implementation intentionally still ignores flags or reports host metadata.\n- The existing review request at Module.cpp:106 remains: 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.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6087402302 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1600#issuecomment-6087402302). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-09T19:02:39Z. --- Issue [#2419](https://github.com/boykopovar/AnyPS5/issues/2419) now includes direct PS5 firmware 13.60 measurements for `sceKernelGetModuleInfoForUnwind`, including the exact `eh_frame` terminator behavior. That evidence is useful for this PR:\n\n- With `flags = 1`, the measured `eh_frame_size` includes the four-byte zero terminator. The current Linux implementation of `sceKernelGetModuleInfoFromAddr` computes that same length (`EhFrameSize` returns 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 empty `name`; flags 0, 3, and 8 return `0x80020016`, flags 2 returns `0x80020003`, and errors zero the entire output. Those behaviors are useful to keep recorded as known differences where this implementation intentionally still ignores `flags` or reports host metadata.\n- The existing review request at `Module.cpp:106` remains: 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.
jweidenh commented 2026-10-09 20:23:51 +00:00 (Migrated from github.com)

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 sceKernelGetModuleInfoFromAddr returns 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:

  • Original PR test: 1/1 passed. Follow-up tests: 2/2 passed.
  • Three controls failed as intended: restoring the silent return; subtracting four from the reported table size; using upstream 8b393b6e's Module.cpp. Restoring the patch returned both tests to passing.
  • Integration e4c9b885, containing this PR, the follow-up and upstream 8b393b6e: 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.
  • The timeouts were agc_driver_flat_store (previously reproduced on upstream d70b8998) and agc_driver_global_vcc_base. The latter also timed out at 30.05 s on clean upstream 8b393b6e, 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.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6088645896 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1600#issuecomment-6088645896). Originally posted by [jweidenh](https://github.com/jweidenh) on 2026-10-09T20:23:51Z. --- I prepared a focused follow-up for the outstanding failed-lookup review request: [commit 132c3a50](https://github.com/jweidenh/AnyPS5/commit/132c3a5080cfb879b9fefed40fb216d73e41fe0c) ([mail patch](https://github.com/jweidenh/AnyPS5/commit/132c3a5080cfb879b9fefed40fb216d73e41fe0c.patch)). It applies directly to this PR's current head, `cfbd3a5c`. The change throws when `sceKernelGetModuleInfoFromAddr` returns 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](https://github.com/boykopovar/AnyPS5/issues/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: - Original PR test: 1/1 passed. Follow-up tests: 2/2 passed. - Three controls failed as intended: restoring the silent return; subtracting four from the reported table size; using upstream `8b393b6e`'s `Module.cpp`. Restoring the patch returned both tests to passing. - [Integration `e4c9b885`](https://github.com/jweidenh/AnyPS5/commit/e4c9b88579d4b83f220fb2a507b796f9a6bd8552), containing this PR, the follow-up and upstream `8b393b6e`: 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. - The timeouts were `agc_driver_flat_store` (previously reproduced on upstream `d70b8998`) and `agc_driver_global_vcc_base`. The latter also timed out at 30.05 s on clean upstream `8b393b6e`, 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.
adriadam10 commented 2026-10-10 00:19:41 +00:00 (Migrated from github.com)

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: FillGuestUnwindInfo now throws when sceKernelGetModuleInfoFromAddr fails, as asked by @oneandonlydean. The patch is @jweidenh's from the thread, cherry-picked (credited as co-author).
  • New guest_unwind_module_info_failure test (symbol interposition, no production hook), and the metadata test now walks the EH records and covers a DSO without an EH header.
  • TechnicalDebt: the eh_frame_size entry 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 with Module.cpp reverted to main. Merging once CI is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6091524496 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1600#issuecomment-6091524496). Originally posted by [adriadam10](https://github.com/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`: `FillGuestUnwindInfo` now throws when `sceKernelGetModuleInfoFromAddr` fails, as asked by @oneandonlydean. The patch is @jweidenh's from the thread, cherry-picked (credited as co-author). - New `guest_unwind_module_info_failure` test (symbol interposition, no production hook), and the metadata test now walks the EH records and covers a DSO without an EH header. - TechnicalDebt: the `eh_frame_size` entry 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 with `Module.cpp` reverted to `main`. Merging once CI is green.
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!1600
No description provided.