fix(relinker): clear Linux guest finalizer arguments #5614
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5614"
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 JJenkx on 2026-10-14T01:11:50Z.
What
Linux guest-module DT_FINI wrappers tail-jumped into guest code with arbitrary host argument registers. A guest finalizer accepting an optional callback could interpret stale RDX as a function pointer. Clear all three guest arguments before the jump, matching the existing macOS wrapper. Startup argument forwarding is unchanged.
The synthetic regression poisons all three arguments and checks zero/null values during direct wrapper invocation and native-loader unload, for modules both with and without DT_INIT.
Tested
Full fork CI passes head
0093322ba1810dbdf06f5115c0b75ac4fab8d4c0against basefeddf7f4c654112663b7576c8a1bc3b87657396d: Linux 1044 passed/46 expected skips; Windows 721 passed/389 expected skips. Expected skips remain unvalidated.The regression fails before the fix. Earlier native RollerCoaster Tycoon Adventures: Deluxe debugging showed this removes an invalid shutdown callback jump; a separate registry-lifetime fix was needed for ordinary exit. That integration result does not establish title compatibility for this standalone PR. The previous d167-based CI Windows attempt timed out in agc_driver_pm4 after its success line; the failed job passed on retry, with the cause unisolated. The fresh run linked above passed.
The branch merges cleanly into main
b16a1a72f3dd824da1c53184d279a14709bdffda; current conventions and whitespace checks pass. Full CI applies to its recorded head/base, not the latest-main merged tree.Independent title evidence
hugodearaujo reports a controlled Hollow Knight: Silksong PPSA12544 test: Linux / RX 9070 XT, main
f0854887dplus #5905, identical libraries and title tree, alternating relinkers with or without this wrapper change. Four baseline exits segfaulted; four with this change did not. Each run waited at the main menu for 60 seconds, then received SIGTERM. Their debugger/disassembly identifies CommonDialog's optional finalizer callback being read from stale RDX. Behavior before exit was unchanged.This is the other contributor's reported evidence on their recorded base, not a new run on my machine or validation against today's main. It links this generic shutdown fix to the Silksong bring-up; it does not claim full title compatibility.
Manual overlap review for #6901 at
be4f4aa72a5c06b5320f1bb8b96e24e312112a95: its listedLinuxGuestModuleWriter.cppstill usescallThrough(image.Fini), so it does not implement this finalizer argument-clearing change. It is not a prerequisite. This branch also passes a fresh local merge-tree check against maind9b696ddbb000991f127dc9f4ba2fd980c517742; this is mergeability evidence, not a fresh full build.Checklist
Imported from boykopovar/AnyPS5. Originally posted by hugodearaujo on 2026-10-14T19:24:41Z.
A title that needs this: Hollow Knight: Silksong (PPSA12544, my own dump) crashes with SIGSEGV every time it exits on Linux, and this PR removes the crash.
What happens. Silksong loads its Unity plugins at run time (
Media/Plugins, relinked with--module-dir Media/Plugins). When the process exits, glibc's_dl_finicalls each plugin'sDT_FINI, which is the plainjmpthis PR replaces.CommonDialog.prx's finalizer takes a callback inrdxand calls it when it is not null:Under gdb (SIGTERM after 60 s at the main menu), the crashing thread is in that call.
rdxwas left by glibc and points into the module's own.dynamic(module base +0x16548;PT_DYNAMICis0x160f8+0x480). The thread then executes the zero bytes there:Measured. RX 9070 XT, Linux,
mainf0854887dwith #5905 (libraries unchanged between the two arms). The only difference is the relinker used for the same title tree,--registry --module-dir Media/Plugins: built from that tree, or with this PR'sLinuxGuestModuleWriter.cppchange on top. Each run waits at the main menu with no input for 60 s, then gets SIGTERM. The runs alternate between the two arms.The title behaves the same until the exit in both arms.
AI-assisted: written with Claude Code; I reviewed the stacks, the disassembly and the runs.
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T12:08:14Z.
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.
core/relinker/CMakeLists.txtcore/relinker/CMakeLists.txtcore/relinker/CMakeLists.txtImported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-16T18:19:20Z.
Checked the finalizer wrapper (
xor edi/esi/edxthenjmp rel32, displacement computed fromstart + 11), built and ran the relinker ctest scope (136/136 pass,guest_module_finiruns natively, not skipped). Reverting onlyLinuxGuestModuleWriter.cppmakesguest_module_finifail, so the test pins the fix. hugodearaujo's A/B on Silksong covers the real-title case. Merging once the full Build is green.Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-16T18:45:08Z.
The current head remains mergeable. The Linux, Windows, and macOS relinker jobs passed, but the full
linuxandwindowsjobs on the Build run were skipped. Could a maintainer dispatch Build on upstreammainwithpr=5614,linux=true, andfull=trueto satisfy the remaining gate? My account has read-only upstream permissions, so I cannot dispatch it. No source changes since the reviewed head0093322ba1810dbdf06f5115c0b75ac4fab8d4c0.