feat(relinker): frame red-zone leaves without a frame pointer by moving their rsp operands #5640

Merged
EagleBearerYS merged 18 commits from upstream-pr/5640 into main 2026-10-24 16:14:54 +00:00
EagleBearerYS commented 2026-10-14 02:36:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-14T02:36:50Z.


What

Why this is back. This closed on 2026-10-14, after #5596 hid Resident Evil Village's (PPSA01556) crash. Grand Theft Auto V (PPSA04264) now hits the same red-zone clobber in zlib's inflate_fast (#9136, the #361 mechanism).

  • A store into a fresh 16 KiB shared MEM_MAPPED view faults and is resumed. Windows writes the exception frame below RSP, over the leaf's red zone.
  • @tibzejoker tied one HDD Streamer crash to a single resumed write in inflate_fast, on the same thread.
  • #5596 avoids the fault for direct memory mapped at one address, but these faults are in shared views it doesn't reach.
  • tibzejoker's port of this PR to GTA V framed 100 of its 917 red-zone leaves, not inflate_fast: 540 were skipped for "rsp operand that cannot move with rsp".
  • It's reopened jointly with tibzejoker, who tests it on GTA V.
  • In tibzejoker's GTA V open-world runs (comment), 3 of 6 unframed diagnostic runs crashed, each right after a single resumed write in inflate_fast on the crashing thread. Framed with this PR and their backward extension (now commit 8 here), 0 of 4 crashed, with resumed writes in two of them. That points to framing as the fix for this crash. It's a small sample, and the framed runs were their build, not this head.

What it does. With --frame-red-zone, on Windows targets, each red-zone leaf the relinker can frame gets a prologue that lowers RSP past its red zone, and exit stubs that raise it back. Its RSP operands move with RSP, so the leaf's own slots stay where it addresses them, and an exception frame Windows writes below RSP lands under them.

  • It builds on @parl0v's #5052 (fab7d203fb), which frames leaves that set up a frame pointer. #5052 is closed. Its commit is carried here unchanged under his authorship.
  • From the first round (743ce530c1, a8ed810d07): leaves without a frame pointer, whose prologue is a chain of pushes, with their RSP operands moved.

New since the close:

  1. The shift fits the leaf (1a262894ad). RSP is lowered only as far as the leaf reaches below it, not a fixed 128 bytes. So more 8-bit displacements keep their encoding.
  2. Leaves that allocate with sub after their pushes (132597c6e1), the shape of inflate_fast.
  3. An execution test (e0ba27fc60), red_zone_framer_execution, on Linux x86-64.
    • It runs each leaf single-stepped, with [rsp-0x80, rsp) filled with 0xa5 before every instruction inside it.
    • Unframed, the leaf must return a wrong value. Framed, it must return the right one.
  4. Operands that can't keep their encoding move to a stub (259bb69d65).
    • Which operands: an 8-bit displacement the shift takes past 0x7f, (%rsp), or (%rsp,%idx,s).
    • The stub holds the operand's instruction, and those after it up to 5 bytes, re-encoded with the moved displacement and a jump back.
    • A stub isn't used when a branch target, a branch, a ret or a RIP-relative instruction falls inside it, or for EVEX forms (scaled disp8). The leaf is then skipped, as before.
  5. Game patches over the framer's writes are refused (10fedd32e3). A game patch over a framed site or a moved displacement is refused with its reason, through GamePatch::CheckOverlaps. Patches elsewhere in a framed leaf are applied before framing, as before.
  6. Function bounds from .eh_frame FDEs. This is @parl0v's commit, 606fa2ef91: his parl0v/AnyPS5@3ff74b9, a follow-up to #5052, carried under his authorship with his agreement (#5052 comment).
    • Each function is decoded from its FDE start to its FDE end, or to int3 padding.
    • Code outside every FDE isn't framed.
    • The relinker stops with an error when the executable has no .eh_frame and framing is asked for.
  7. Each leaf decoded over its whole FDE range (a376e37b88).
    • The first round's body cut (a8ed810d07) is dropped. With FDE bounds it isn't needed, and it left a cold block after a ret inside the same FDE undecoded: its operands weren't moved and its exit wasn't stubbed.
    • The case the first round's debt entry listed as unhandled, a pointer-only leaf right after a loop's back-edge jmp, is now framed from its own FDE.
  8. A short operand's stub also takes the instructions before it (e410c38b42, tested in cec1f82d76). This is @tibzejoker's idea and diff (comment), and the commit is co-authored by them.
    • When the instruction after an operand that can't move in place is a branch, a RIP-relative instruction or the add that frees the frame, the stub could stay shorter than a jump and the leaf was skipped.
    • The stub now also takes the contiguous sequential instructions before the operand, with their own RSP operands moved by the shift. The branch-target, framed-site and existing-stub checks run on the widened range.
    • zlib's inflate_fast frames this way: its one operand left, a 4-byte cmp %rdi,(%rsp), sits between an add and a jne.
    • red_zone_framer's leaf with its RSP operand before a RIP-relative load now frames. The one with its operand right before an exit stays refused, because its forward extension reaches the exit's pops.

The debt entries and USAGE.md describe the new shapes (a665ef2dfb, 542cb30f70). Inside a moved frame, the CFA rules of the guest's unwind tables are off by the shift; the debt entry records it.

Still skipped: exits shorter than a jump, indirect jumps, other uses of RSP (copying it into another register), branches out of the function, an operand with no room for a stub, and EVEX operands.

Tested

  • GTA V (PPSA04264) on this head, by @tibzejoker (comment): RTX 4090, Windows 11, main 3bbd2321d with #9730, #9181, #9159 and #9445, and this PR's commits up to cec1f82d76 cherry-picked; relinked with --frame-red-zone, the per-rip fault log and APS5_MIMALLOC=1, four open-world runs of up to 420 s.

    • The framer: 243 of the 991 red-zone leaves are framed, inflate_fast among them, and 1 "rsp operand that cannot move and has no room for a stub" is left. In the relinked image inflate_fast's spills sit above RSP, and its cmp %rdi,(%rsp) at 0x28aac88 jumps to its stub.
    • The runs: at least 49 resumed writes inside inflate_fast across the four runs (at least 44 in run 1 alone, at six different rips), and no HDD Streamer crash. Their log keeps only the 1st, 2nd, 3rd, 10th and 100th hit of each rip, so the counts are lower bounds.
    • Run 2 ended at about 150 s on the separate alpha-to-coverage limit in State.cpp (dithered alpha-to-coverage requires eight matched raster/DB_EQAA samples and one pixel iteration), which main hits too; it isn't a red-zone symptom. Runs 1, 3 and 4 ran the full 420 s.
    • With the four earlier runs on the backward extension, that's 0 red-zone crashes in 8 framed runs. Unframed, on #9136's diagnostic build (a different base), every run that took even one such write crashed on that thread: 3 of 3.
  • GTA V (PPSA04264), by @tibzejoker (comment), Windows 11, i9-13900K, RTX 4090, with a376e37b88's commits cherry-picked onto their tree:

    • 240 of the 991 red-zone leaves are framed, against 100 in their first port. inflate_fast is one of the 4 left with "rsp operand that cannot move and has no room for a stub".
    • With their backward extension (commit 8 here), 243 are framed, inflate_fast among them. In 4 open-world runs of 7 minutes with APS5_MIMALLOC=1 there were 0 crashes, and two runs still took a resumed write inside inflate_fast, which the game carried on through.
  • The backward extension, on GitHub's runners (run, whose head has the same trees as cec1f82d76; red with e410c38b42's change reverted):

    • Cases: two leaves whose cmp %rdi,(%rsp) sits before a jne, after an add (inflate_fast's shape) and after a load below RSP that heads the loop and moves inside the stub. A cmp whose loop branches back to it stays refused, since the widened stub would cover the branch target. The execution test runs both framed leaves under the writes below RSP.
    • Red: red_zone_framer and red_zone_framer_execution fail on Linux, and red_zone_framer on Windows.
    • Green: on Linux, all 5 tests of the set (with relinker_conversion, relinker_executables and relinker_game_patch) pass 10 runs in a row; on Windows, 4 of 4 (the execution test is registered on Linux x86-64 only); none skipped or failed. The libc and libkernel suites pass on both, run with APS5_SKIP_TIMING_TESTS=1, which relaxes precise_wait's median bounds on GitHub's hosted runners.
  • Linux x86-64, CI's configure flags (on a cloud worker):

    • The relinker's tests: all 171 pass at each of the six newest commits, and check_test_registration.py reports nothing new.
    • red_zone_framer: 23 cases, parl0v's two included.
    • red_zone_framer_execution: 20 of 20 runs, together with red_zone_framer and relinker_game_patch.
  • The execution test's leaves (each run unframed and framed, with the writes below RSP):

    Leaf Returns without the writes Unframed, with them Framed, with them
    #5640's frameless shape, a spill 0x10 below RSP 0x19998 0x5a5a5a5a5a5a5a50 0x19998
    a leaf reaching 0x28 below RSP 0x33330 0x8787878787878778 0x33330
    a positive disp8 moved in place (saved rbx at +0x10) 0x2aaa8 0x2d2d2d2d2d2f4f48 0x2aaa8
    lea of a slot 0x20 below RSP 0x19998 0x5a5a5a5a5a5a5a50 0x19998
    inflate_fast's shape: six pushes, then sub $0x40 0x11110 0x9696969696976360 0x11110
    sub $0x70 with (%rsp) and 0x60(%rsp) in stubs 0x19998 0x969696969697ebe8 0x19998
    the whole 0x80 shift, reading saved rbx at 0x8(%rsp) 0x2aaa8 0x2d2d2d2d2d2f4f48 0x2aaa8
    • Mutant, a fixed 0x10 shift: fails "leaf reaching 0x28 below rsp: the framed leaf returned 0x5a5a5a5a5a5bf3e8 under writes below rsp".
    • Mutant, stubs that keep the old displacement: fails "the framed leaf returned 0x1dddc without the clobber".
  • Red/green per commit:

    • Operand stubs: red on the framer before them, "only 0 of 2 leaves were framed".
    • Patch refusal: red without it, the patch over the moved displacement at 0x1049 accepted.
    • FDE bounds: two adjacent leaves, a tail call past the FDE end, and a leaf after a back-edge jmp. All three are red on the framer before parl0v's commit.
    • The cold block after a ret: red on parl0v's commit alone, "the exit of a cold block after the ret inside the FDE was not framed".
  • Real code under the same writes, as a scratch check on our own clang 18 -O2 builds of open-source libraries, framed in memory the way the Windows trampolines are:

    • zlib: compress2 level 9, and the inflate of its stream (inflate_fast, inflate_table). Framed, the output is unchanged. Unframed, compress ends in a SIGSEGV, and inflate returns Z_DATA_ERROR after 111 steps with the writes.
    • zstd and mbedtls: zstd levels 1, 3, 5 and 9, compress and decompress, and mbedtls base64. Framed, the output is unchanged. Unframed, zstd's first run ends in a SIGSEGV.
    • Counts:
      • zlib: 4 of its 6 red-zone leaves framed, inflate_fast and inflate_table among them;
      • a mixed sample (zlib, zstd, mbedtls, ogg, spng, LibAtrac9): 33 of 61 framed, against 28 before the stubs and FDE bounds.
  • Windows:

    • MinGW -fsyntax-only -Wall -Wextra of the touched relinker files: 0 errors and no new warnings.
    • GitHub's Windows runner (run 39909023950, on a376e37b88): red_zone_framer and relinker_game_patch pass 3 of 3 runs, along with the libc and libkernel suites. red_zone_framer_execution is registered on Linux x86-64 only.
  • Not tested again: Resident Evil Village. Its crash didn't reproduce on main with #5596: 0 of 17 boots, measured on 2026-10-14 (comment). It hasn't been checked again since.

Checklist

  • Based on main 3875f8c8ff (merged in), and merges cleanly into 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 under Silent stubs in their library's technical debt file
  • 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 (none added)
  • Generic behaviour, not specific to one title
  • Depends on: none (of the 61 open relinker PRs, the 11 that conflict with this one also conflict with main, in the same files or more)
  • Fixes: none (Related: #9136, #361, #5052)
  • Unblocks: PPSA04264 #1203: the HDD Streamer's red-zone crash in inflate_fast (tibzejoker's runs above)
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4852152994 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5640). Originally posted by [EagleBearerYS](https://github.com/EagleBearerYS) on 2026-10-14T02:36:50Z. --- ### What **Why this is back.** This closed on 2026-10-14, after #5596 hid Resident Evil Village's (PPSA01556) crash. Grand Theft Auto V (PPSA04264) now hits the same red-zone clobber in zlib's `inflate_fast` (#9136, the #361 mechanism). - A store into a fresh 16 KiB shared `MEM_MAPPED` view faults and is resumed. Windows writes the exception frame below RSP, over the leaf's red zone. - @tibzejoker [tied one HDD Streamer crash to a single resumed write in `inflate_fast`](https://github.com/boykopovar/AnyPS5/issues/9136#issuecomment-6356302049), on the same thread. - #5596 avoids the fault for direct memory mapped at one address, but these faults are in shared views it doesn't reach. - tibzejoker's [port of this PR to GTA V](https://github.com/boykopovar/AnyPS5/issues/9136#issuecomment-6356343541) framed 100 of its 917 red-zone leaves, not `inflate_fast`: 540 were skipped for "rsp operand that cannot move with rsp". - It's reopened jointly with tibzejoker, who tests it on GTA V. - In tibzejoker's GTA V open-world runs ([comment](https://github.com/boykopovar/AnyPS5/issues/9136#issuecomment-6368622069)), 3 of 6 unframed diagnostic runs crashed, each right after a single resumed write in `inflate_fast` on the crashing thread. Framed with this PR and their backward extension (now commit 8 here), 0 of 4 crashed, with resumed writes in two of them. That points to framing as the fix for this crash. It's a small sample, and the framed runs were their build, not this head. **What it does.** With `--frame-red-zone`, on Windows targets, each red-zone leaf the relinker can frame gets a prologue that lowers RSP past its red zone, and exit stubs that raise it back. Its RSP operands move with RSP, so the leaf's own slots stay where it addresses them, and an exception frame Windows writes below RSP lands under them. - It builds on @parl0v's #5052 (fab7d203fb), which frames leaves that set up a frame pointer. #5052 is closed. Its commit is carried here unchanged under his authorship. - **From the first round** (743ce530c1, a8ed810d07): leaves without a frame pointer, whose prologue is a chain of pushes, with their RSP operands moved. **New since the close:** 1. **The shift fits the leaf** (1a262894ad). RSP is lowered only as far as the leaf reaches below it, not a fixed 128 bytes. So more 8-bit displacements keep their encoding. 2. **Leaves that allocate with `sub` after their pushes** (132597c6e1), the shape of `inflate_fast`. 3. **An execution test** (e0ba27fc60), `red_zone_framer_execution`, on Linux x86-64. - It runs each leaf single-stepped, with `[rsp-0x80, rsp)` filled with `0xa5` before every instruction inside it. - Unframed, the leaf must return a wrong value. Framed, it must return the right one. 4. **Operands that can't keep their encoding move to a stub** (259bb69d65). - Which operands: an 8-bit displacement the shift takes past `0x7f`, `(%rsp)`, or `(%rsp,%idx,s)`. - The stub holds the operand's instruction, and those after it up to 5 bytes, re-encoded with the moved displacement and a jump back. - A stub isn't used when a branch target, a branch, a `ret` or a RIP-relative instruction falls inside it, or for EVEX forms (scaled disp8). The leaf is then skipped, as before. 5. **Game patches over the framer's writes are refused** (10fedd32e3). A game patch over a framed site or a moved displacement is refused with its reason, through `GamePatch::CheckOverlaps`. Patches elsewhere in a framed leaf are applied before framing, as before. 6. **Function bounds from `.eh_frame` FDEs.** This is @parl0v's commit, 606fa2ef91: his parl0v/AnyPS5@3ff74b9, a follow-up to #5052, carried under his authorship with his agreement ([#5052 comment](https://github.com/boykopovar/AnyPS5/pull/5052#issuecomment-6356932607)). - Each function is decoded from its FDE start to its FDE end, or to int3 padding. - Code outside every FDE isn't framed. - The relinker stops with an error when the executable has no `.eh_frame` and framing is asked for. 7. **Each leaf decoded over its whole FDE range** (a376e37b88). - The first round's body cut (a8ed810d07) is dropped. With FDE bounds it isn't needed, and it left a cold block after a `ret` inside the same FDE undecoded: its operands weren't moved and its exit wasn't stubbed. - The case the first round's debt entry listed as unhandled, a pointer-only leaf right after a loop's back-edge `jmp`, is now framed from its own FDE. 8. **A short operand's stub also takes the instructions before it** (e410c38b42, tested in cec1f82d76). This is @tibzejoker's idea and diff ([comment](https://github.com/boykopovar/AnyPS5/pull/5640#issuecomment-6366829405)), and the commit is co-authored by them. - When the instruction after an operand that can't move in place is a branch, a RIP-relative instruction or the `add` that frees the frame, the stub could stay shorter than a jump and the leaf was skipped. - The stub now also takes the contiguous sequential instructions before the operand, with their own RSP operands moved by the shift. The branch-target, framed-site and existing-stub checks run on the widened range. - zlib's `inflate_fast` frames this way: its one operand left, a 4-byte `cmp %rdi,(%rsp)`, sits between an `add` and a `jne`. - `red_zone_framer`'s leaf with its RSP operand before a RIP-relative load now frames. The one with its operand right before an exit stays refused, because its forward extension reaches the exit's pops. The debt entries and `USAGE.md` describe the new shapes (a665ef2dfb, 542cb30f70). Inside a moved frame, the CFA rules of the guest's unwind tables are off by the shift; the debt entry records it. **Still skipped:** exits shorter than a jump, indirect jumps, other uses of RSP (copying it into another register), branches out of the function, an operand with no room for a stub, and EVEX operands. ### Tested - **GTA V (PPSA04264) on this head, by @tibzejoker** ([comment](https://github.com/boykopovar/AnyPS5/pull/5640#issuecomment-6370763162)): RTX 4090, Windows 11, `main` 3bbd2321d with #9730, #9181, #9159 and #9445, and this PR's commits up to cec1f82d76 cherry-picked; relinked with `--frame-red-zone`, the per-`rip` fault log and `APS5_MIMALLOC=1`, four open-world runs of up to 420 s. - **The framer:** 243 of the 991 red-zone leaves are framed, `inflate_fast` among them, and 1 "rsp operand that cannot move and has no room for a stub" is left. In the relinked image `inflate_fast`'s spills sit above RSP, and its `cmp %rdi,(%rsp)` at 0x28aac88 jumps to its stub. - **The runs:** at least 49 resumed writes inside `inflate_fast` across the four runs (at least 44 in run 1 alone, at six different `rip`s), and no HDD Streamer crash. Their log keeps only the 1st, 2nd, 3rd, 10th and 100th hit of each `rip`, so the counts are lower bounds. - Run 2 ended at about 150 s on the separate alpha-to-coverage limit in `State.cpp` (`dithered alpha-to-coverage requires eight matched raster/DB_EQAA samples and one pixel iteration`), which `main` hits too; it isn't a red-zone symptom. Runs 1, 3 and 4 ran the full 420 s. - With the four earlier runs on the backward extension, that's 0 red-zone crashes in 8 framed runs. Unframed, on #9136's diagnostic build (a different base), every run that took even one such write crashed on that thread: 3 of 3. - **GTA V (PPSA04264), by @tibzejoker** ([comment](https://github.com/boykopovar/AnyPS5/pull/5640#issuecomment-6366829405)), Windows 11, i9-13900K, RTX 4090, with a376e37b88's commits cherry-picked onto their tree: - 240 of the 991 red-zone leaves are framed, against 100 in their first port. `inflate_fast` is one of the 4 left with "rsp operand that cannot move and has no room for a stub". - With their backward extension (commit 8 here), 243 are framed, `inflate_fast` among them. In 4 open-world runs of 7 minutes with `APS5_MIMALLOC=1` there were 0 crashes, and two runs still took a resumed write inside `inflate_fast`, which the game carried on through. - **The backward extension, on GitHub's runners** ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/39979915116), whose head has the same trees as cec1f82d76; red with e410c38b42's change reverted): - **Cases:** two leaves whose `cmp %rdi,(%rsp)` sits before a `jne`, after an `add` (`inflate_fast`'s shape) and after a load below RSP that heads the loop and moves inside the stub. A `cmp` whose loop branches back to it stays refused, since the widened stub would cover the branch target. The execution test runs both framed leaves under the writes below RSP. - **Red:** `red_zone_framer` and `red_zone_framer_execution` fail on Linux, and `red_zone_framer` on Windows. - **Green:** on Linux, all 5 tests of the set (with `relinker_conversion`, `relinker_executables` and `relinker_game_patch`) pass 10 runs in a row; on Windows, 4 of 4 (the execution test is registered on Linux x86-64 only); none skipped or failed. The libc and libkernel suites pass on both, run with `APS5_SKIP_TIMING_TESTS=1`, which relaxes `precise_wait`'s median bounds on GitHub's hosted runners. - **Linux x86-64, CI's configure flags (on a cloud worker):** - **The relinker's tests:** all 171 pass at each of the six newest commits, and `check_test_registration.py` reports nothing new. - **`red_zone_framer`:** 23 cases, parl0v's two included. - **`red_zone_framer_execution`:** 20 of 20 runs, together with `red_zone_framer` and `relinker_game_patch`. - **The execution test's leaves** (each run unframed and framed, with the writes below RSP): | Leaf | Returns without the writes | Unframed, with them | Framed, with them | |---|---|---|---| | #5640's frameless shape, a spill 0x10 below RSP | 0x19998 | 0x5a5a5a5a5a5a5a50 | 0x19998 | | a leaf reaching 0x28 below RSP | 0x33330 | 0x8787878787878778 | 0x33330 | | a positive disp8 moved in place (saved rbx at +0x10) | 0x2aaa8 | 0x2d2d2d2d2d2f4f48 | 0x2aaa8 | | `lea` of a slot 0x20 below RSP | 0x19998 | 0x5a5a5a5a5a5a5a50 | 0x19998 | | `inflate_fast`'s shape: six pushes, then `sub $0x40` | 0x11110 | 0x9696969696976360 | 0x11110 | | `sub $0x70` with `(%rsp)` and `0x60(%rsp)` in stubs | 0x19998 | 0x969696969697ebe8 | 0x19998 | | the whole 0x80 shift, reading saved rbx at `0x8(%rsp)` | 0x2aaa8 | 0x2d2d2d2d2d2f4f48 | 0x2aaa8 | - **Mutant, a fixed 0x10 shift:** fails "leaf reaching 0x28 below rsp: the framed leaf returned 0x5a5a5a5a5a5bf3e8 under writes below rsp". - **Mutant, stubs that keep the old displacement:** fails "the framed leaf returned 0x1dddc without the clobber". - **Red/green per commit:** - **Operand stubs:** red on the framer before them, "only 0 of 2 leaves were framed". - **Patch refusal:** red without it, the patch over the moved displacement at `0x1049` accepted. - **FDE bounds:** two adjacent leaves, a tail call past the FDE end, and a leaf after a back-edge `jmp`. All three are red on the framer before parl0v's commit. - **The cold block after a `ret`:** red on parl0v's commit alone, "the exit of a cold block after the ret inside the FDE was not framed". - **Real code under the same writes**, as a scratch check on our own clang 18 `-O2` builds of open-source libraries, framed in memory the way the Windows trampolines are: - **zlib:** `compress2` level 9, and the inflate of its stream (`inflate_fast`, `inflate_table`). Framed, the output is unchanged. Unframed, compress ends in a SIGSEGV, and inflate returns `Z_DATA_ERROR` after 111 steps with the writes. - **zstd and mbedtls:** zstd levels 1, 3, 5 and 9, compress and decompress, and mbedtls base64. Framed, the output is unchanged. Unframed, zstd's first run ends in a SIGSEGV. - **Counts:** - zlib: 4 of its 6 red-zone leaves framed, `inflate_fast` and `inflate_table` among them; - a mixed sample (zlib, zstd, mbedtls, ogg, spng, LibAtrac9): 33 of 61 framed, against 28 before the stubs and FDE bounds. - **Windows:** - MinGW `-fsyntax-only -Wall -Wextra` of the touched relinker files: 0 errors and no new warnings. - GitHub's Windows runner ([run 39909023950](https://github.com/EagleBearerYS/AnyPS5/actions/runs/39909023950), on a376e37b88): `red_zone_framer` and `relinker_game_patch` pass 3 of 3 runs, along with the libc and libkernel suites. `red_zone_framer_execution` is registered on Linux x86-64 only. - **Not tested again:** Resident Evil Village. Its crash didn't reproduce on `main` with #5596: 0 of 17 boots, measured on 2026-10-14 ([comment](https://github.com/boykopovar/AnyPS5/pull/5640#issuecomment-6169852126)). It hasn't been checked again since. ### Checklist - [x] Based on `main` 3875f8c8ff (merged in), and merges cleanly into 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 under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [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 (none added) - [x] Generic behaviour, not specific to one title - [x] Depends on: none (of the 61 open relinker PRs, the 11 that conflict with this one also conflict with `main`, in the same files or more) - [x] Fixes: none (Related: #9136, #361, #5052) - [x] Unblocks: PPSA04264 #1203: the HDD Streamer's red-zone crash in `inflate_fast` (tibzejoker's runs above) - [x] GPUs tested: n/a - [x] AI-assisted: yes
adriadam10 commented 2026-10-14 12:39:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-14T12:39:42Z.

Review: CHANGES_REQUESTED


Thanks for the detailed write-up. Two blockers before this can be reviewed:

  • Base PR is closed. Depends on: #5052 was closed unmerged on 2026-10-14, so this branch still carries its whole RedZoneFramer (the diff against main is +659) plus Josip Parlov's commit. Either coordinate with them to reopen/land it, or resubmit as a self-contained PR with the authorship preserved.
  • Motivation has changed. #361 is now fixed at the source by #5596 (merged). On #5052 parl0v measured 0 crashes in 20 boots of PPSA25344 without the flag on main with #5596. Please re-measure the Village boot crash (2 of 5 without framing) on current main with #5596 included, with and without --frame-red-zone. If it no longer reproduces, there is nothing for this opt-in pass to fix.

If it still reproduces, also note that #5052's review asked for function bounds from the .eh_frame FDEs (EhFrameReader) rather than heuristics; the "end of body" rule added in a8ed810d0 (aligned code after ret/ud2, jmp to padding) is a heuristic that leaves a documented gap, so it should use the FDEs here too.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5518007283 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5640#pullrequestreview-5518007283). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-14T12:39:42Z. **Review:** CHANGES_REQUESTED --- Thanks for the detailed write-up. Two blockers before this can be reviewed: - **Base PR is closed.** `Depends on: #5052` was closed unmerged on 2026-10-14, so this branch still carries its whole `RedZoneFramer` (the diff against `main` is +659) plus Josip Parlov's commit. Either coordinate with them to reopen/land it, or resubmit as a self-contained PR with the authorship preserved. - **Motivation has changed.** #361 is now fixed at the source by #5596 (merged). On #5052 parl0v measured 0 crashes in 20 boots of PPSA25344 without the flag on `main` with #5596. Please re-measure the Village boot crash (2 of 5 without framing) on current `main` with #5596 included, with and without `--frame-red-zone`. If it no longer reproduces, there is nothing for this opt-in pass to fix. If it still reproduces, also note that #5052's review asked for function bounds from the `.eh_frame` FDEs (`EhFrameReader`) rather than heuristics; the "end of body" rule added in a8ed810d0 (aligned code after `ret`/`ud2`, `jmp` to padding) is a heuristic that leaves a documented gap, so it should use the FDEs here too.
EagleBearerYS commented 2026-10-14 13:46:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-14T13:46:36Z.


Re-measured on current main with #5596: Resident Evil Village (PPSA01556, 01.210.000), Windows 11 Home 10.0.26300, RTX 3070 Laptop (driver 617.42), unframed (relinked with main's relinker).

  • On our stack from before #5596, stop 21 (#361) hit 35-52 s into a boot, as a GameThread access violation, a null read at app.exe+0x69cb959, in 2 of 5 boots.
  • On main with #5596 it doesn't reproduce, 0 of 17 boots:
  • Both sets carry local commits that prepare shaders at their first draw (APS5_RE8_LAZY_PREPARE=1, with APS5_NO_GPL=1). Most also have local fixes for later stops.

So there's nothing left for this pass to fix in Village, and I'm closing it. Thanks for the review. parl0v's .eh_frame version (parl0v/AnyPS5@3ff74b9) is the starting point if a title needs framing again.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6169852126 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5640#issuecomment-6169852126). Originally posted by [EagleBearerYS](https://github.com/EagleBearerYS) on 2026-10-14T13:46:36Z. --- Re-measured on current `main` with #5596: Resident Evil Village (PPSA01556, 01.210.000), Windows 11 Home 10.0.26300, RTX 3070 Laptop (driver 617.42), unframed (relinked with `main`'s relinker). - On our stack from before #5596, stop 21 (#361) hit 35-52 s into a boot, as a GameThread access violation, a null read at `app.exe+0x69cb959`, in 2 of 5 boots. - On `main` with #5596 it doesn't reproduce, 0 of 17 boots: - 10 boots to 120 s, back to back, on `main` 23be5a02b + #5688 + #5703 + #5815. None faulted, and several had reached the start-up autosave notice by then. - 7 earlier boots that ran past that window, 95 s to 32 min each, on `main` at 0b6d033b8, eac1e26e2 and 23be5a02b, six of them with #5688 and #5703. - Both sets carry local commits that prepare shaders at their first draw (`APS5_RE8_LAZY_PREPARE=1`, with `APS5_NO_GPL=1`). Most also have local fixes for later stops. So there's nothing left for this pass to fix in Village, and I'm closing it. Thanks for the review. parl0v's `.eh_frame` version (parl0v/AnyPS5@3ff74b9) is the starting point if a title needs framing again.
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!5640
No description provided.