fix(relinker): end the guest frame-pointer chain at the entry stub #2339
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2339"
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 johnmaia on 2026-10-09T15:51:35Z.
What
The entry stubs call the title's entry with
rbp= 0: on Linux as the process starts, on Windows as the argument loop (dec ebp) leaves it. The title's start code pushesrbp, so the frame-pointer chain of its main thread ends in a null frame pointer.Unreal Engine walks that chain to capture a call stack (for a fatal error or an ensure). It stops at a return address of 0, but it reads
[rbp + 8]of each saved frame pointer first, so a null link makes it read address 8 and crash. On the console the chain ends in a frame record whose return address is 0.rbp0, return address 0) and pointsrbpat it beforecall. Two 8-byte pushes keep the 16-byte alignment at the call.rsp+0x40,rsp+0x48; it uses0x20-0x3cand0x58-0x5c) and pointsrbpat it before calling the entry.Tested
Linux (Ubuntu 24.04, GCC 13.3), RX 7600.
entry_stubtest: the Linux stub passes the initial stack pointer, aligns, pushes the zero record, pointsrbpat it, clearsrsi, calls the entry and ends withud2.ctest517/517.tools/check_conventions.pyandtools/check_test_registration.pypass.0x186cfbf,mov 0x8(%rdx),%raxwithrdx= 0, after following the chain to the stub'srbp.saved=0 ret=0), so Unreal reports its own error instead of crashing in the walk. Here that isLowLevelFatalError ... RemoveFromOuterMap NumRemoved = 0, a separate problem.Guest threads started by
RunThreadcall their entry from host frames too. That needs a trampoline with unwind information and is left for a separate change.Overlaps #2097, which changes the same function's call encoding: its new test helper reads the call at
entry + 10, and with this change the call is atentry + 17. Whichever lands second needs that offset updated.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_0134RWCyiyydJBbfKz8g9Bwe
Imported from boykopovar/AnyPS5. Originally posted by Kikoarl on 2026-10-09T17:52:44Z.
Tested on Linux (CachyOS x86_64, Intel RPL-S iGPU / Mesa 26.3.0-devel / Vulkan 1.4.363, GCC 16.2.1) at
60a614cf:/tmp/anyps5_build) with zero warnings/errors.python3 tools/check_conventions.py --base origin/main --head HEAD-> PASS (0 errors).EntryStubBuilder.cpp. Prevents stack unwinding from walking into unmapped host memory past the entry stub.LGTM!
Imported from boykopovar/AnyPS5. Originally posted by Yuva1024 on 2026-10-10T02:38:21Z.
Windows results, since the description has Linux only.
mainc963432dwith this PR merged (--no-ff, as the Build workflow does); Windows 11 (26200), WinLibs GCC 15.2.0 r7, Release, Ryzen 5 5600G, RTX 4060.ctest: 573/574.entry_stubpasses. The one failure isvideo_out_flip_lifetime, which aborts intermittently on unchangedmaintoo (filed as #2540); this merge only rebuilds the relinker.0x60; the stub and its helpers only addressrsp+0x20..0x3fand the dword at0x58, andWindowsGuestStartuphas norsp-relative accesses, so0x40..0x4fis free as described.main_fixtureentry replaced withmov rax,[rbp]; or rax,[rbp+8]; jnz bad; mov eax,42; ret, converted with--windowsand run:main:0xc0000005in 3/3 runs (rbpis 0 at the entry).rbppoints at a{0, 0}record).Not tested on a title.
AI-assisted: yes (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-10T04:21:00Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)core/relinker/elfpatcher/tests/EntryStubTests.cpp