fix(mods): a hook entered with BL that goes back with B returns, where that is safe #3166

Merged
HumanBean merged 2 commits from snaildev99/Longshot:mods/exefs-bl-return into main 2026-12-05 17:28:13 +00:00
Member

Summary

Many code mods hook the game by writing bl my_hook over one of its instructions, and the hook jumps back with
b <the instruction after the call> because its own calls have used up the return register. On the console that jump
is a return. In a recompiled build it is not: the lift makes bl a call and the jump a branch inside the hook, so the
hook runs the rest of the game's function (its epilogue) inside the call, then returns into it, and the game runs that
rest a second time with its stack frame gone. It crashes a few calls up (Character Select v0.1.2 did, on the old
builder).

With this change the build writes such a jump back as RET before the code is lifted, when that is exactly the same
thing: when nothing but that one call can reach the hook's code (no other branch or call, no instruction above falling
in, no unwind start, function symbol, relocated pointer or ADR / ADRP+ADD address, in any switch state). Otherwise it
leaves the jump and says why in the build log and the file's note. The pass runs after the switches are planned, over
the files the build takes (a mod that is off and no switch takes no part). The RET goes into the writes of each
file that writes the branch, in the image and in the switch table: two mods with the same hook, each behind its own
switch, both get it, so the hook returns with either on. A hook that only jumps on through a register (a trampoline
into a code module's hook, or a tail call) has no way back and stays quiet.

How to see it on main: the_lifted_hook_leaves_the_callers_epilogue_in_the_caller (build-driver's driver test)
lifts a synthetic game with such a hook; on main the hook's lifted function holds the caller's epilogue.

This is the Rust port of #960. It is stacked on #3165 (the overlap pass runs first and hands this pass the
final writes), so its diff holds that PR's commit (d30a27407) until it merges. Review the last two commits: the test,
then the fix.

Read first: builder/crates/game-files/src/returns.rs (make_returns, Hook::walk, Code::writers), then where
patches::collect calls it.

Testing

Tested: Windows 11 Pro, RTX 3090, NVIDIA 610.88, in the game, built by longshot-builder play --profile with
this PR and the other mod compatibility ports merged, adult Link in Kakariko, with four code mods (HUD of Time, Rupee
Counter, Ragdoll Button, Edge-to-Edge). Their hooks are trampolines (bl into a stub that jumps on with br). The
first build said each "has an indirect jump: left as it is, it may not run as on the console"; that was wrong, a
trampoline has no way back, and the fix's last change keeps them quiet (test
a_trampoline_that_jumps_on_through_a_register_stays_quiet). After it the build says nothing about returns and the
mods work in the game. None of these mods has a hook that goes back with b, so no return was made in the game.
After the rebase and the review's fixes, here @ ad9338505, built with the other ports merged (929bf025a), the same
profile again: the build says nothing about returns, and the mods work in Kakariko.
Game-free: the 20 tests of returns_tests.rs and the two driver tests, below. After the review two cases were added
and fixed: a later mod that is off and built out over the hook's call (a_later_mod_left_out_of_the_build_hides_no_call:
the analysis took it in, missed the call and left the B), and two mods with the same hook
(two_mods_with_the_same_hook_each_return, and the driver's
two_mods_with_the_same_hook_return_in_every_switch_state, which lifts each switch state: with only the earlier
mod on, its hook still ran the caller's RET at +18). Each fails on the test commit and passes now, and each fails
again with its fix's key lines undone (the pass back before the switch plan, over every file that applies; only
the last writer as owner, the earlier head's rule).

Rebased onto #3165 @ d30a27407 (main @ 3a0f7d8f7), here @ ad9338505: cargo test -p game-files 93 passed (89 in the library, 4 in its other targets);
cargo test -p build-driver --test driver 11 passed; clippy -p game-files -p build-driver --no-deps --all-targets -- -D warnings clean (without --no-deps it stops on main's own errors: host-sys's "large array defined as
const" and an unused import in build-core's sandbox_windows.rs); rustfmt clean; tests/test_doc_anchors.py
passes.

mise run test, run locally while CI's run waits for approval (Windows 11, tests/run_all.py --strict, 12 checks at
once), here @ ad9338505 and on main @ 3a0f7d8f7: 847 passed, 12 failed, 52 skipped here; 845 passed, 14 failed, 52
skipped on main. All 12 also fail on main: test_dlssg, test_fsr4_tune, test_lifter, test_no_game_title,
test_no_map_reload, test_present_acquire_ahead, test_present_geometry_trace, test_present_held_image,
test_present_image_free, test_sync_watch_event, test_turf_budget, test_ui_renderer.

Still to test:

  • Windows: a mod whose hook goes back to its call with b (Character Select v0.1.2's patch), expecting the log to
    say the branch was made a return and the mod's menu to work without a crash (by hand)
  • Windows: build time and size against main (measurement, the review's L4)

Measurements

Verdict: Fixed in the lift: the tests that fail without the fix pass, and the other cases keep their branch with a
note. Nothing changes per frame; the pass runs in the build only when a patch writes a bl into code it also writes.

Setup: cargo test of game-files and build-driver on Windows 11; the before side is the test commit
(5df5a805e), which is #3165's code (d30a27407, on main @ 3a0f7d8f7) with the tests.

Baseline: the test commit, not main, because this PR stacks on #3165 (its overlap pass makes the final writes the
fix reads); the test commit is that code with this PR's tests and without the fix.

Before: the test commit @ 5df5a805e After: this PR @ ad9338505
cargo test -p game-files returns_tests 2 passed, 18 failed 20 passed
cargo test -p build-driver --test driver the_lifted_hook_leaves_the_callers_epilogue_in_the_caller 1 failed (the hook holds the caller's epilogue) 1 passed
cargo test -p build-driver --test driver two_mods_with_the_same_hook_return_in_every_switch_state 1 failed 1 passed
cargo test -p game-files (the 18 above fail) 93 passed

Risks

  • The proof starts from the all-on image and the entries main knows. An indirect jump table the analysis doesn't
    see, or an entry only the lift adds, could still reach a routine made a return. Then the mod's hook would return
    early where the console would have run on.
  • An instruction a code patch writes unchanged now counts as the patch's, so switch tables can grow a little.
  • The proof asks that the return file's mod writes the hook's call and routine, no longer that it is their last
    writer; another file that could change one of them in some switch state still keeps the B.
  • Players: a mod with such a hook stops crashing; its file note says what was done. A revert is enough.

Checklist

Ready for review

  • One topic, on current main; the title is a Conventional Commit.
  • Tested on my own PC, in the game for a change the game runs, as Testing says.
  • mise run test passes (any failure that also fails on main is named). (run locally, Testing names them; CI's run waits for approval)
  • Measured against main, or Measurements says why there is nothing to measure.
  • No game files, build output or hand-edited generated files; third_party/ untouched; nothing GPL-incompatible.

When it applies

  • A fix: a game-free test that fails on main and passes here.
  • A check under tests/ that reads changed source is updated, not weakened. (tests/test_parity_gates.py reads loader/mod.rs's log lines, which this keeps: it passes unchanged)
  • Docs updated.
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.

Ready to merge

  • Everything in Still to test has run, its results in Tested.
  • Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers").
  • Approved in review, every comment answered.
  • CI passes on the head; on current main, measured again or a comment says why the numbers still hold.

🤖 Generated with Claude Code

## Summary Many code mods hook the game by writing `bl my_hook` over one of its instructions, and the hook jumps back with `b <the instruction after the call>` because its own calls have used up the return register. On the console that jump is a return. In a recompiled build it is not: the lift makes `bl` a call and the jump a branch inside the hook, so the hook runs the rest of the game's function (its epilogue) inside the call, then returns into it, and the game runs that rest a second time with its stack frame gone. It crashes a few calls up (Character Select v0.1.2 did, on the old builder). With this change the build writes such a jump back as `RET` before the code is lifted, when that is exactly the same thing: when nothing but that one call can reach the hook's code (no other branch or call, no instruction above falling in, no unwind start, function symbol, relocated pointer or ADR / ADRP+ADD address, in any switch state). Otherwise it leaves the jump and says why in the build log and the file's note. The pass runs after the switches are planned, over the files the build takes (a mod that is off and no switch takes no part). The `RET` goes into the writes of each file that writes the branch, in the image and in the switch table: two mods with the same hook, each behind its own switch, both get it, so the hook returns with either on. A hook that only jumps on through a register (a trampoline into a code module's hook, or a tail call) has no way back and stays quiet. How to see it on `main`: `the_lifted_hook_leaves_the_callers_epilogue_in_the_caller` (build-driver's `driver` test) lifts a synthetic game with such a hook; on `main` the hook's lifted function holds the caller's epilogue. This is the Rust port of #960. **It is stacked on #3165** (the overlap pass runs first and hands this pass the final writes), so its diff holds that PR's commit (d30a27407) until it merges. Review the last two commits: the test, then the fix. Read first: `builder/crates/game-files/src/returns.rs` (`make_returns`, `Hook::walk`, `Code::writers`), then where `patches::collect` calls it. ## Testing **Tested:** Windows 11 Pro, RTX 3090, NVIDIA 610.88, in the game, built by `longshot-builder play --profile` with this PR and the other mod compatibility ports merged, adult Link in Kakariko, with four code mods (HUD of Time, Rupee Counter, Ragdoll Button, Edge-to-Edge). Their hooks are trampolines (`bl` into a stub that jumps on with `br`). The first build said each "has an indirect jump: left as it is, it may not run as on the console"; that was wrong, a trampoline has no way back, and the fix's last change keeps them quiet (test `a_trampoline_that_jumps_on_through_a_register_stays_quiet`). After it the build says nothing about returns and the mods work in the game. None of these mods has a hook that goes back with `b`, so no return was made in the game. After the rebase and the review's fixes, here @ ad9338505, built with the other ports merged (929bf025a), the same profile again: the build says nothing about returns, and the mods work in Kakariko. Game-free: the 20 tests of `returns_tests.rs` and the two driver tests, below. After the review two cases were added and fixed: a later mod that is off and built out over the hook's call (`a_later_mod_left_out_of_the_build_hides_no_call`: the analysis took it in, missed the call and left the B), and two mods with the same hook (`two_mods_with_the_same_hook_each_return`, and the driver's `two_mods_with_the_same_hook_return_in_every_switch_state`, which lifts each switch state: with only the earlier mod on, its hook still ran the caller's RET at +18). Each fails on the test commit and passes now, and each fails again with its fix's key lines undone (the pass back before the switch plan, over every file that applies; only the last writer as owner, the earlier head's rule). Rebased onto #3165 @ d30a27407 (`main` @ 3a0f7d8f7), here @ ad9338505: `cargo test -p game-files` 93 passed (89 in the library, 4 in its other targets); `cargo test -p build-driver --test driver` 11 passed; `clippy -p game-files -p build-driver --no-deps --all-targets -- -D warnings` clean (without `--no-deps` it stops on `main`'s own errors: `host-sys`'s "large array defined as const" and an unused import in `build-core`'s `sandbox_windows.rs`); rustfmt clean; `tests/test_doc_anchors.py` passes. `mise run test`, run locally while CI's run waits for approval (Windows 11, `tests/run_all.py --strict`, 12 checks at once), here @ ad9338505 and on `main` @ 3a0f7d8f7: 847 passed, 12 failed, 52 skipped here; 845 passed, 14 failed, 52 skipped on `main`. All 12 also fail on `main`: test_dlssg, test_fsr4_tune, test_lifter, test_no_game_title, test_no_map_reload, test_present_acquire_ahead, test_present_geometry_trace, test_present_held_image, test_present_image_free, test_sync_watch_event, test_turf_budget, test_ui_renderer. **Still to test:** - Windows: a mod whose hook goes back to its call with `b` (Character Select v0.1.2's patch), expecting the log to say the branch was made a return and the mod's menu to work without a crash (by hand) - Windows: build time and size against `main` (measurement, the review's L4) ## Measurements **Verdict:** Fixed in the lift: the tests that fail without the fix pass, and the other cases keep their branch with a note. Nothing changes per frame; the pass runs in the build only when a patch writes a `bl` into code it also writes. Setup: `cargo test` of `game-files` and `build-driver` on Windows 11; the before side is the test commit (5df5a805e), which is #3165's code (d30a27407, on `main` @ 3a0f7d8f7) with the tests. Baseline: the test commit, not `main`, because this PR stacks on #3165 (its overlap pass makes the final writes the fix reads); the test commit is that code with this PR's tests and without the fix. | | Before: the test commit @ 5df5a805e | After: this PR @ ad9338505 | |---|---|---| | `cargo test -p game-files returns_tests` | 2 passed, 18 failed | 20 passed | | `cargo test -p build-driver --test driver the_lifted_hook_leaves_the_callers_epilogue_in_the_caller` | 1 failed (the hook holds the caller's epilogue) | 1 passed | | `cargo test -p build-driver --test driver two_mods_with_the_same_hook_return_in_every_switch_state` | 1 failed | 1 passed | | `cargo test -p game-files` | (the 18 above fail) | 93 passed | ## Risks - The proof starts from the all-on image and the entries `main` knows. An indirect jump table the analysis doesn't see, or an entry only the lift adds, could still reach a routine made a return. Then the mod's hook would return early where the console would have run on. - An instruction a code patch writes unchanged now counts as the patch's, so switch tables can grow a little. - The proof asks that the return file's mod writes the hook's call and routine, no longer that it is their last writer; another file that could change one of them in some switch state still keeps the B. - Players: a mod with such a hook stops crashing; its file note says what was done. A revert is enough. ## Checklist ### Ready for review - [x] One topic, on current `main`; the title is a Conventional Commit. - [x] Tested on my own PC, in the game for a change the game runs, as Testing says. - [x] `mise run test` passes (any failure that also fails on `main` is named). (run locally, Testing names them; CI's run waits for approval) - [x] Measured against `main`, or Measurements says why there is nothing to measure. - [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible. ### When it applies - [x] A fix: a game-free test that fails on `main` and passes here. - [x] A check under `tests/` that reads changed source is updated, not weakened. (`tests/test_parity_gates.py` reads `loader/mod.rs`'s log lines, which this keeps: it passes unchanged) - [x] Docs updated. - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. ### Ready to merge - [ ] Everything in Still to test has run, its results in Tested. - [ ] Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers"). - [ ] Approved in review, every comment answered. - [ ] CI passes on the head; on current `main`, measured again or a comment says why the numbers still hold. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
feat(mods): two mods' ExeFS patches that write one place differently are named, and the lower one wins every byte
Some checks failed
PR description / Title and description (pull_request_target) Successful in 6s
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Third-party parts and guide screenshots (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
f4071ee12d
The port of #961 to the Rust builder (the Python one cannot be rebased).

Where two patch files wrote the same byte, the one lower in the list won and nobody was told. collect() now compares
the files as written and names every such place: in the build's log ("<file> wins by list order where 120 bytes
differ (main+84-FB). Also written by <file>.") and in each file's note in exefs_patches.txt, which the Mods tab shows
before the file's other notes, so a long note cannot hide the clash. Three or more writers are named as they are: the
winner, then every other file on that place.

The lower file now also wins where it writes the game's own byte back over a higher file's change. Main::classify
leaves out the bytes a file writes that equal the game's, so such a byte was not applied and the higher file's byte
stayed: a mix of two mods' code that neither wrote. Those bytes are put back into the lower file's writes, and a file
that was empty (every byte the game's) becomes code or data when it puts bytes back. A place two mods write
differently is not split by a byte they write alike.

Restart switching: every mod that writes a byte another mod writes differently, on or off at the build, is built in
and switches at the next build, so the byte that wins is the same at every start. A mod's own files switch together,
so a byte only they dispute takes nothing from its switch: its lower file's byte is put back whether it is on or off.
The other mods keep their switches. collect() now runs
the hook-site refusal (a callback, build-driver's clashes::refuse) before the comparison, and plans the switches
after it, so a refused file takes no part and a later pass over the files' final writes has one place to go.

Each file is parsed once.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A patch that calls its hook with BL and resumes with B to the instruction after the call: the lifted hook follows the
B into the caller, so the caller's continuation runs twice. These checks collect such patches (one file, two files of
one mod, other mods on and off, branches and calls from elsewhere, relocations, switch states) and check the words
the game and the lift get, the switch table, and each file's note; the driver's check lifts one. On main the B stays
a B, and the lifted hook runs the caller's RET.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
fix(mods): a hook entered with BL that goes back with B returns, where that is safe
Some checks failed
PR description / Title and description (pull_request_target) Successful in 6s
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Third-party parts and guide screenshots (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
07621fa328
The port of #960 to the Rust builder.

The lift makes BL a C call and RET a C return; a B to code that is no function start becomes a goto. A mod's hook is
often `bl hook` written over one of the game's instructions, going back with `b <the call's next instruction>`
because its own calls have used up x30. On the console that B is a return. Translated, the hook's C function runs the
rest of its caller inside the call and then returns into the caller, which runs that rest again with its frame gone
(Character Select v0.1.2 crashed so, two calls up).

collect() now ends with returns::make_returns, over the files' final writes: such a B is written as RET, in the file
that wrote it, when the hook's routine (what is reached from the call's target, up to its returns and up to the
call's next instruction) was all written by the patches and is entered from that one call alone: no other direct
branch or call into it, no instruction above it falling in, no unwind start, function symbol, relocated pointer,
init or fini, or ADR / ADRP+ADD address in it. The proof holds for every state the file can be used in: another file
switched off, or refused, even one of the same mod, can neither supply the call nor hide a way in. Otherwise the B
stays and the file's note says why it may not run as on the console (entered from elsewhere too, it runs the game's
own code, the way back is conditional, or an indirect jump).

Main::classify keeps the whole instructions a code file supplies even where they equal the game's, so the pass can
tell an instruction of the patch from a gap that runs the game's own code. game-files uses the a64 crate's decoder.

The tests are returns_tests.rs (each case of the old test_exefs_bl_return.py, and the switch states) and build-driver's
the_lifted_hook_leaves_the_callers_epilogue_in_the_caller, which lifts a hook and checks the caller keeps its epilogue.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Member

Tested in game: Windows 11 Pro, RTX 3090, NVIDIA 610.88, adult Link in Kakariko, built by longshot-builder play --profile with the mod compatibility ports merged, with four code mods (HUD of Time, Rupee Counter, Ragdoll Button, Edge-to-Edge) whose hooks are trampolines (bl into a stub that jumps on with br). The first build wrongly noted each as having an indirect jump; with this head the build says nothing about returns and the mods work in the game. None of these mods has a hook that goes back with b, so no return was made in the game: that case is the driver test.

Tested in game: Windows 11 Pro, RTX 3090, NVIDIA 610.88, adult Link in Kakariko, built by longshot-builder play --profile with the mod compatibility ports merged, with four code mods (HUD of Time, Rupee Counter, Ragdoll Button, Edge-to-Edge) whose hooks are trampolines (bl into a stub that jumps on with br). The first build wrongly noted each as having an indirect jump; with this head the build says nothing about returns and the mods work in the game. None of these mods has a hook that goes back with b, so no return was made in the game: that case is the driver test.
Author
Member

mise run test, run locally while CI's run waits for approval: 824 passed, 21 failed, 51 skipped here @ 07621fa32; 18 of the 21 also fail on main @ f577a1aea (named in Testing), the other three timed out under load and pass here run alone (--exact). tests/test_parity_gates.py, which reads loader/mod.rs, passes unchanged. Boxes ticked.

mise run test, run locally while CI's run waits for approval: 824 passed, 21 failed, 51 skipped here @ 07621fa32; 18 of the 21 also fail on main @ f577a1aea (named in Testing), the other three timed out under load and pass here run alone (--exact). tests/test_parity_gates.py, which reads loader/mod.rs, passes unchanged. Boxes ticked.
snaildev99 changed title from WIP: fix(mods): a hook entered with BL that goes back with B returns, where that is safe to fix(mods): a hook entered with BL that goes back with B returns, where that is safe 2026-12-05 02:25:25 +00:00
BeanBot left a comment

Recommendation: Request changes. The return pass can miss an active hook when an overlapping mod is off, and it can leave an identical hook unfixed when only one of two switches is enabled. Both cases retain the crash this change is intended to prevent.

The builder detects some BL hooks that branch back to their callers and replaces safe branches with returns. It also reports overlapping patch writes and changes which overlapping mods require a rebuild to switch.

Blocking (3): must change before merging.

  1. L1 builder/crates/game-files/src/returns.rs:43: The analysis includes off files that the overlap pass will later make build-time-only, so it can analyze an image different from the one actually built. (more on the line) Do: Plan or otherwise identify build-time-only off files before constructing the analysis image, and analyze the actual built image plus the switch states that can really occur. Add a test with an enabled hook and a later disabled conflicting patch.
  2. L2 builder/crates/game-files/src/returns.rs:400: Only the last writer receives the return even when another independently switched file supplies the same hook. (more on the line) Do: Handle every reachable switch state that supplies the branch, for example by safely rewriting each eligible writer or making the overlapping hooks switch together. Add a test that lifts the earlier-only state of two identical hooks.
  3. L5: It conflicts with its base branch: bring it up to date (@​fix or @​rebase try first). (for the author)

Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)

  • L3 builder/crates/game-files/src/returns.rs:328: The target behavior has not yet been exercised with a real hook that branches back. (more on the line) Do: Build and play with a mod containing a BL hook that returns with B, checking the conversion note and the affected feature on Windows and Linux.
  • L4 builder/crates/game-files/src/patches.rs:553: The build cost of scanning code and patch alternatives has not been measured. (more on the line) Do: Measure clean and incremental build time and output size against the base with representative code mods, as the builder standards require.

@fix can do L1 and L2.

Checks: Still running: 11 checks.

More: does it help, other systems, switches, what was read

Does it help: Unproven in the game for the target hook: the reported synthetic driver test failed before and passed after, but the in-game run used only trampolines and made no returns. Build-time cost has not been measured.

Other systems: The pass affects patched code and switch variants on Windows and Linux, regardless of GPU. The reported Windows game run covers trampoline mods, but not an actual rewritten return; Linux and the stated target mod have not been run. The overlap pass also changes restart-versus-rebuild behavior for conflicting mods.

Switches: No environment variables or developer switches added. Mods that write different values to a shared byte now require a rebuild to switch; nonconflicting mods retain restart switches. Identical overlapping hooks need additional handling for independent switch states.

Reviewed: 07621fa328 against f577a1aeab: Read the repository rules, PR template, commit log, return analysis, return tests, switch planning, patch collection and application paths, and changed diffs. Skimmed the larger loader and driver files, documentation changes, lockfile, and related lift discovery references; did not read every changed code file in full. docs/review-checklist.md was absent.; nothing run (a code review).

Checked and fine:

  • The synthetic driver test checks lifted control flow and includes a before-fix assertion.
  • The commits include AI-assistance trailers.
  • No renderer API, shader, third-party, or generated file change appears in the diff.

Testing: Read-only review; no builds, tests, scripts, or game runs were executed. The author reports 18 return tests and the driver test passing on Windows, and CI is still running.

Overlaps and merge order: Stacked on Longshot#3165; that overlap pass should merge first.


Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, as snaildev99 took it out of WIP. Nothing was run; a maintainer decides.

**Recommendation: Request changes.** The return pass can miss an active hook when an overlapping mod is off, and it can leave an identical hook unfixed when only one of two switches is enabled. Both cases retain the crash this change is intended to prevent. The builder detects some BL hooks that branch back to their callers and replaces safe branches with returns. It also reports overlapping patch writes and changes which overlapping mods require a rebuild to switch. **Blocking (3)**: must change before merging. 1. **L1** `builder/crates/game-files/src/returns.rs:43`: The analysis includes off files that the overlap pass will later make build-time-only, so it can analyze an image different from the one actually built. (more on the line) **Do:** Plan or otherwise identify build-time-only off files before constructing the analysis image, and analyze the actual built image plus the switch states that can really occur. Add a test with an enabled hook and a later disabled conflicting patch. 2. **L2** `builder/crates/game-files/src/returns.rs:400`: Only the last writer receives the return even when another independently switched file supplies the same hook. (more on the line) **Do:** Handle every reachable switch state that supplies the branch, for example by safely rewriting each eligible writer or making the overlapping hooks switch together. Add a test that lifts the earlier-only state of two identical hooks. 3. **L5**: It conflicts with its base branch: bring it up to date (`@​fix` or `@​rebase` try first). *(for the author)* **Testing before merging (2)** (runs on the systems it can change; it doesn't hold the recommendation) - **L3** `builder/crates/game-files/src/returns.rs:328`: The target behavior has not yet been exercised with a real hook that branches back. (more on the line) **Do:** Build and play with a mod containing a BL hook that returns with B, checking the conversion note and the affected feature on Windows and Linux. - **L4** `builder/crates/game-files/src/patches.rs:553`: The build cost of scanning code and patch alternatives has not been measured. (more on the line) **Do:** Measure clean and incremental build time and output size against the base with representative code mods, as the builder standards require. `@fix` can do L1 and L2. **Checks:** Still running: 11 checks. <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Unproven in the game for the target hook: the reported synthetic driver test failed before and passed after, but the in-game run used only trampolines and made no returns. Build-time cost has not been measured. **Other systems:** The pass affects patched code and switch variants on Windows and Linux, regardless of GPU. The reported Windows game run covers trampoline mods, but not an actual rewritten return; Linux and the stated target mod have not been run. The overlap pass also changes restart-versus-rebuild behavior for conflicting mods. **Switches:** No environment variables or developer switches added. Mods that write different values to a shared byte now require a rebuild to switch; nonconflicting mods retain restart switches. Identical overlapping hooks need additional handling for independent switch states. **Reviewed:** 07621fa328ad against f577a1aeabdb: Read the repository rules, PR template, commit log, return analysis, return tests, switch planning, patch collection and application paths, and changed diffs. Skimmed the larger loader and driver files, documentation changes, lockfile, and related lift discovery references; did not read every changed code file in full. docs/review-checklist.md was absent.; nothing run (a code review). **Checked and fine:** - The synthetic driver test checks lifted control flow and includes a before-fix assertion. - The commits include AI-assistance trailers. - No renderer API, shader, third-party, or generated file change appears in the diff. **Testing:** Read-only review; no builds, tests, scripts, or game runs were executed. The author reports 18 return tests and the driver test passing on Windows, and CI is still running. **Overlaps and merge order:** Stacked on Longshot#3165; that overlap pass should merge first. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, as snaildev99 took it out of WIP. Nothing was run; a maintainer decides.</sub>
@ -513,0 +550,4 @@
refuse(&mut out)?;
let diagnostics: Vec<_> = out.iter().map(|f| f.note.clone()).collect();
let fixed = overlaps(&m, &mut out, written, log);
// (the return pass reads the final writes: after the overlaps put the lower files' bytes back, which can make a file
Member

L4 (should fix): The build cost of scanning code and patch alternatives has not been measured.

When: A build with code patches now scans the code range and analyzes alternate writes; players wait for this work during the build.

Do: Measure clean and incremental build time and output size against the base with representative code mods, as the builder standards require.

**L4** (should fix): The build cost of scanning code and patch alternatives has not been measured. *When:* A build with code patches now scans the code range and analyzes alternate writes; players wait for this work during the build. **Do:** Measure clean and incremental build time and output size against the base with representative code mods, as the builder standards require.
@ -0,0 +40,4 @@
let end = main.segments[1].offset.min(main.image.len() as u64) & !3;
let range = main.segments[0].offset..end;
let mut edits = BTreeMap::<u64, Vec<Edit>>::new();
for (i, file) in files.iter().enumerate().filter(|(_, f)| f.kind.applies()) {
Member

L1 (blocking): The analysis includes off files that the overlap pass will later make build-time-only, so it can analyze an image different from the one actually built.

When: An enabled mod supplies a BL hook and its branch back, while a later disabled mod writes a different instruction over the BL. The overlap pass fixes both mods at build time, but Code::new still overlays the disabled file; the call is not discovered, then switch planning drops that file. The enabled hook is built with its original branch and can execute the caller's epilogue twice.

Do: Plan or otherwise identify build-time-only off files before constructing the analysis image, and analyze the actual built image plus the switch states that can really occur. Add a test with an enabled hook and a later disabled conflicting patch.

**L1** (blocking): The analysis includes off files that the overlap pass will later make build-time-only, so it can analyze an image different from the one actually built. *When:* An enabled mod supplies a BL hook and its branch back, while a later disabled mod writes a different instruction over the BL. The overlap pass fixes both mods at build time, but Code::new still overlays the disabled file; the call is not discovered, then switch planning drops that file. The enabled hook is built with its original branch and can execute the caller's epilogue twice. **Do:** Plan or otherwise identify build-time-only off files before constructing the analysis image, and analyze the actual built image plus the switch states that can really occur. Add a test with an enabled hook and a later disabled conflicting patch.
@ -0,0 +325,4 @@
}
/// Write each safe return into its last writer, before the image, switch table and lift take those bytes.
pub(crate) fn make_returns(main: &Nso, files: &mut [PatchFile], log: &mut dyn FnMut(String)) -> Result<()> {
Member

L3 (should fix): The target behavior has not yet been exercised with a real hook that branches back.

When: The reported game run used trampoline hooks, so it never executed a return produced by this pass.

Do: Build and play with a mod containing a BL hook that returns with B, checking the conversion note and the affected feature on Windows and Linux.

**L3** (should fix): The target behavior has not yet been exercised with a real hook that branches back. *When:* The reported game run used trampoline hooks, so it never executed a return produced by this pass. **Do:** Build and play with a mod containing a BL hook that returns with B, checking the conversion note and the affected feature on Windows and Linux.
@ -0,0 +397,4 @@
} else {
let start = file.writes.partition_point(|&(o, _)| o < at);
let end = file.writes.partition_point(|&(o, _)| o < at + 4);
file.writes.splice(start..end, (at..at + 4).zip(RET.to_le_bytes()));
Member

L2 (blocking): Only the last writer receives the return even when another independently switched file supplies the same hook.

When: Two mods write identical copies of a BL hook and its branch back. Their bytes do not conflict, so both retain switches; the all-on analysis assigns the exit to the later mod and rewrites only that file. With the earlier mod on and the later one off, the earlier file still supplies the original branch, so its hook can run the caller's continuation twice.

Do: Handle every reachable switch state that supplies the branch, for example by safely rewriting each eligible writer or making the overlapping hooks switch together. Add a test that lifts the earlier-only state of two identical hooks.

**L2** (blocking): Only the last writer receives the return even when another independently switched file supplies the same hook. *When:* Two mods write identical copies of a BL hook and its branch back. Their bytes do not conflict, so both retain switches; the all-on analysis assigns the exit to the later mod and rewrites only that file. With the earlier mod on and the later one off, the earlier file still supplies the original branch, so its hook can run the caller's continuation twice. **Do:** Handle every reachable switch state that supplies the branch, for example by safely rewriting each eligible writer or making the overlapping hooks switch together. Add a test that lifts the earlier-only state of two identical hooks.
snaildev99 force-pushed mods/exefs-bl-return from 07621fa328
Some checks failed
PR description / Title and description (pull_request_target) Successful in 6s
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Third-party parts and guide screenshots (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
to ad93385051
Some checks failed
PR description / Title and description (pull_request_target) Has been cancelled
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Third-party parts and guide screenshots (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
2026-12-05 10:44:40 +00:00
Compare
Author
Member

Rebased onto #3165's rebased commit (main @ 3a0f7d8f7) for the base conflict; here @ ad9338505. Tested (the game again on this head), mise run test (against main @ 3a0f7d8f7: every failure also fails on main) and Measurements are updated. Answers to the review below.

Rebased onto #3165's rebased commit (main @ 3a0f7d8f7) for the base conflict; here @ ad9338505. Tested (the game again on this head), `mise run test` (against main @ 3a0f7d8f7: every failure also fails on main) and Measurements are updated. Answers to the review below.
Author
Member

L1 (the analysis sees off files the overlap pass builds out): fixed in ad9338505. collect now plans the switches first and runs the return pass after, over the files the build takes (PatchFile::takes: on, or behind a switch). A mod that is off and no switch, such as one the overlap pass builds in or out, is left out of the analysis as it is left out of the image, so it can no longer hide the hook's call. The RETs still reach the switch table, which is made from the files' final writes after collect. New test a_later_mod_left_out_of_the_build_hides_no_call (in 5df5a805e): the hook's mod on, a later mod off that writes another instruction over the call. Before the fix the image kept the B; now it gets the RET and the hook file's note says so.

L2 (only the last writer gets the return): fixed in ad9338505. Every file that writes the branch by itself now gets the RET where the proof holds with that file present (Code::writers): the last writer as before, and each earlier one whose RET no later file's partial bytes could mix with. The proof's same-mod check now asks that the RET file's mod writes the call and the routine, rather than being their last writer; the check of the other files' alternatives is unchanged and still refuses any state in which another file changes them. New tests (in 5df5a805e): two_mods_with_the_same_hook_each_return (each mod alone and both: RET in the image and in both switches' table rows, both notes) and build-driver's two_mods_with_the_same_hook_return_in_every_switch_state, which lifts the two identical hooks and checks that the version with only the earlier switch on, as well as the later-only version and the all-on function, ends at the hook's RET. Both fail on the test commit, and again with the owner put back to the last writer alone (the earlier head's rule): the unit test at "first on", the driver test at "first on alone", whose lifted hook still runs on to the caller's RET at +18.

L3 (a real hook that branches back, in the game): still to run: none of the mods on this PC has such a hook. It stays in Still to test (Character Select v0.1.2's patch, by hand). On this head, built with the other ports merged, the four code mods' trampolines still build with no word about returns, and the mods work in the game.

L4 (build cost): still to measure: the build time and size against main (Still to test).

L5 (conflicts with main): rebased onto #3165's rebased commit (on main @ 3a0f7d8f7). One conflict, in docs/dev/reference/mods.md: #3165's sentence on overlap notes (now with its note bound) and this PR's paragraph on returns, both kept.

**L1** (the analysis sees off files the overlap pass builds out): fixed in ad9338505. `collect` now plans the switches first and runs the return pass after, over the files the build takes (`PatchFile::takes`: on, or behind a switch). A mod that is off and no switch, such as one the overlap pass builds in or out, is left out of the analysis as it is left out of the image, so it can no longer hide the hook's call. The RETs still reach the switch table, which is made from the files' final writes after `collect`. New test `a_later_mod_left_out_of_the_build_hides_no_call` (in 5df5a805e): the hook's mod on, a later mod off that writes another instruction over the call. Before the fix the image kept the B; now it gets the RET and the hook file's note says so. **L2** (only the last writer gets the return): fixed in ad9338505. Every file that writes the branch by itself now gets the RET where the proof holds with that file present (`Code::writers`): the last writer as before, and each earlier one whose RET no later file's partial bytes could mix with. The proof's same-mod check now asks that the RET file's mod writes the call and the routine, rather than being their last writer; the check of the other files' alternatives is unchanged and still refuses any state in which another file changes them. New tests (in 5df5a805e): `two_mods_with_the_same_hook_each_return` (each mod alone and both: RET in the image and in both switches' table rows, both notes) and build-driver's `two_mods_with_the_same_hook_return_in_every_switch_state`, which lifts the two identical hooks and checks that the version with only the earlier switch on, as well as the later-only version and the all-on function, ends at the hook's RET. Both fail on the test commit, and again with the owner put back to the last writer alone (the earlier head's rule): the unit test at "first on", the driver test at "first on alone", whose lifted hook still runs on to the caller's RET at +18. **L3** (a real hook that branches back, in the game): still to run: none of the mods on this PC has such a hook. It stays in Still to test (Character Select v0.1.2's patch, by hand). On this head, built with the other ports merged, the four code mods' trampolines still build with no word about returns, and the mods work in the game. **L4** (build cost): still to measure: the build time and size against `main` (Still to test). **L5** (conflicts with `main`): rebased onto #3165's rebased commit (on `main` @ 3a0f7d8f7). One conflict, in `docs/dev/reference/mods.md`: #3165's sentence on overlap notes (now with its note bound) and this PR's paragraph on returns, both kept.
Author
Member

Merge note for #3166 and #3216: each passes alone on main, but whichever merges second needs a two-line test fix. #3216 gives write_image in builder/crates/build-driver/tests/driver.rs a second argument (the writes), and #3166's two return tests call it with one: write_image(&d, &[]). With all the mod compatibility ports merged together, that is the only change it needed there.

Merge note for #3166 and #3216: each passes alone on `main`, but whichever merges second needs a two-line test fix. #3216 gives `write_image` in `builder/crates/build-driver/tests/driver.rs` a second argument (the writes), and #3166's two return tests call it with one: `write_image(&d, &[])`. With all the mod compatibility ports merged together, that is the only change it needed there.
Owner
@review
BeanBot left a comment

Recommendation: Approve. The code is ready: only testing is left. The two reported code defects are fixed, but the target behavior still needs a real in-game hook test and the build cost remains unmeasured. The PR is also stacked on #3165. Recommend approval; not approved on the forge.

The builder turns a safe branch back from a mod hook into a return, preventing the lifted caller’s continuation from running twice. The pass adds build-time analysis and can increase switch-table writes.

Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)

  • L3 builder/crates/game-files/src/returns.rs:328: The target behavior has not yet been exercised with a real hook that branches back. When: The reported game run used trampoline hooks, so it never executed a return produced by this pass. Do: Build and play with a mod containing a BL hook that returns with B, checking the conversion note and the affected feature on Windows and Linux.
  • L4 builder/crates/game-files/src/patches.rs:553: The build cost of scanning code and patch alternatives has not been measured. When: A build with code patches now scans the code range and analyzes alternate writes; players wait for this work during the build. Do: Measure clean and incremental build time and output size against the base with representative code mods, as the builder standards require.

Since the last review (on 07621fa328)
Resolved: L1 (The analysis includes off files that the overlap pass will later make build-time-only, so…); L2 (Only the last writer receives the return even when another independently switched file sup…); L5 (It conflicts with its base branch: bring it up to date (@​fix or @​rebase try first).)
Still open: L3 (The target behavior has not yet been exercised with a real hook that branches back.); L4 (The build cost of scanning code and patch alternatives has not been measured.)

Checks: Still running: 11 checks.

More: does it help, other systems, switches, what was read

Does it help: Unproven in the game for the target hook: the recorded synthetic tests pass after the fix, while the tested in-game mods use trampolines and did not trigger a return. Build time and size have not been measured.

Other systems: The pass affects patch collection, switch states and lifted game code on Windows and Linux. The recorded game run covers Windows and trampoline hooks; a real branch-back hook remains untested.

Switches: No player-facing switch added, changed or removed. Existing mod switches now receive the return in each qualifying file.

Reviewed: ad93385051 against 3a0f7d8f7f: Read AGENTS.md, CONTRIBUTING.md, the pull request template, returns.rs and switches.rs; inspected the supplied range-diff and review context. The full base diff and all changed files were not read in full; docs/review-checklist.md was absent.; nothing run (a code review).

Checked and fine:

  • The recorded two-mod tests cover each switch alone and both together.
  • The recorded excluded-mod test covers a later off file over the hook call.

Testing: No commands that build or run tests were executed. The author reports 20 return tests and both driver tests passing, plus an in-game Windows run with trampoline mods; CI is still running.

Overlaps and merge order: Stacked on #3165, which should merge first. #3216 also changes the driver test helper; whichever merges second needs its return-test calls updated.


Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.

**Recommendation: Approve.** The code is ready: only testing is left. The two reported code defects are fixed, but the target behavior still needs a real in-game hook test and the build cost remains unmeasured. The PR is also stacked on #3165. Recommend approval; not approved on the forge. The builder turns a safe branch back from a mod hook into a return, preventing the lifted caller’s continuation from running twice. The pass adds build-time analysis and can increase switch-table writes. **Testing before merging (2)** (runs on the systems it can change; it doesn't hold the recommendation) - **L3** `builder/crates/game-files/src/returns.rs:328`: The target behavior has not yet been exercised with a real hook that branches back. *When:* The reported game run used trampoline hooks, so it never executed a return produced by this pass. **Do:** Build and play with a mod containing a BL hook that returns with B, checking the conversion note and the affected feature on Windows and Linux. - **L4** `builder/crates/game-files/src/patches.rs:553`: The build cost of scanning code and patch alternatives has not been measured. *When:* A build with code patches now scans the code range and analyzes alternate writes; players wait for this work during the build. **Do:** Measure clean and incremental build time and output size against the base with representative code mods, as the builder standards require. **Since the last review** (on 07621fa328ad) Resolved: L1 (The analysis includes off files that the overlap pass will later make build-time-only, so…); L2 (Only the last writer receives the return even when another independently switched file sup…); L5 (It conflicts with its base branch: bring it up to date (`@​fix` or `@​rebase` try first).) Still open: L3 (The target behavior has not yet been exercised with a real hook that branches back.); L4 (The build cost of scanning code and patch alternatives has not been measured.) **Checks:** Still running: 11 checks. <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Unproven in the game for the target hook: the recorded synthetic tests pass after the fix, while the tested in-game mods use trampolines and did not trigger a return. Build time and size have not been measured. **Other systems:** The pass affects patch collection, switch states and lifted game code on Windows and Linux. The recorded game run covers Windows and trampoline hooks; a real branch-back hook remains untested. **Switches:** No player-facing switch added, changed or removed. Existing mod switches now receive the return in each qualifying file. **Reviewed:** ad93385051f6 against 3a0f7d8f7f34: Read AGENTS.md, CONTRIBUTING.md, the pull request template, returns.rs and switches.rs; inspected the supplied range-diff and review context. The full base diff and all changed files were not read in full; docs/review-checklist.md was absent.; nothing run (a code review). **Checked and fine:** - The recorded two-mod tests cover each switch alone and both together. - The recorded excluded-mod test covers a later off file over the hook call. **Testing:** No commands that build or run tests were executed. The author reports 20 return tests and both driver tests passing, plus an in-game Windows run with trampoline mods; CI is still running. **Overlaps and merge order:** Stacked on #3165, which should merge first. #3216 also changes the driver test helper; whichever merges second needs its return-test calls updated. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.</sub>
Owner
@rebase
Member

I rebased this pull request onto main (3145d9d48f): the new head is bdcac619bf.

Nothing was built or run: read the resolution before merging.


Automated rebase by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.

I rebased this pull request onto `main` (3145d9d48f05): the new head is bdcac619bf1d. Nothing was built or run: read the resolution before merging. --- <sub>Automated rebase by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.</sub>
BeanBot force-pushed mods/exefs-bl-return from ad93385051
Some checks failed
PR description / Title and description (pull_request_target) Has been cancelled
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Third-party parts and guide screenshots (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
to bdcac619bf
Some checks failed
PR description / Title and description (pull_request_target) Failing after 8s
CI / What the change needs (pull_request) Successful in 9s
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Waiting to run
CI / Website build and checks (pull_request) Waiting to run
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Waiting to run
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Waiting to run
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Waiting to run
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Waiting to run
CI / Third-party parts and guide screenshots (pull_request) Successful in 13s
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Successful in 18s
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has started running
2026-12-05 17:19:58 +00:00
Compare
BeanBot left a comment

Recommendation: Approve. The code is ready: only testing is left. The synthetic tests show the hook return is corrected, but the target behavior has not yet been exercised with a real mod in the game, and build cost remains unmeasured. Recommend approval; not approved on the forge.

The builder converts a safe branch back from a mod hook into a return, preventing the caller’s epilogue from running twice. It adds build-time code and patch-alternative analysis.

Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)

  • L3 builder/crates/game-files/src/returns.rs:328: The target behavior has not yet been exercised with a real hook that branches back. When: The reported game run used trampoline hooks, so it never executed a return produced by this pass. Do: Build and play with a mod containing a BL hook that returns with B, checking the conversion note and the affected feature on Windows and Linux.
  • L4 builder/crates/game-files/src/patches.rs:553: The build cost of scanning code and patch alternatives has not been measured. When: A build with code patches now scans the code range and analyzes alternate writes; players wait for this work during the build. Do: Measure clean and incremental build time and output size against the base with representative code mods, as the builder standards require.

Since the last review (on ad93385051)
Still open: L3 (The target behavior has not yet been exercised with a real hook that branches back.); L4 (The build cost of scanning code and patch alternatives has not been measured.)

Checks: they run again on this head; a failure shows on the pull request.

More: does it help, other systems, switches, what was read

Does it help: Unproven in a real game hook. The reported synthetic tests changed from 18 failures to 20 passes in game-files, and both relevant driver tests passed after failing before the fix; no tested game mod used the branch-back pattern.

Other systems: The pass affects builds on Windows and Linux and switch-dependent patch states. The reported Windows game run exercised trampoline mods, while the target branch-back hook and build cost remain untested.

Switches: No switches added, changed or removed. Existing mod switch states are considered by the analysis.

Reviewed: bdcac619bf against 3145d9d48f: Read the repository rules and PR template, the commit list and diff summary, and the return pass and patch integration diff. The remaining changed files, tests and supporting callers were not read in full in this re-check.; nothing run (a code review).

Checked and fine:

  • The recorded synthetic tests cover the intended return behavior and multiple switch states.
  • The rebase leaves no changed lines within the pull request diff since the previous review.

Testing: No commands that build or run tests were executed. The author reports 93 game-files tests and 11 driver tests passing, plus a Windows game run with trampoline mods; CI has not run on this head.

Overlaps and merge order: #3216 changes the driver test helper signature; whichever PR merges second needs the reported two-line test adjustment. The PR was stacked on #3165, whose commit is no longer in this diff.


Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, after its rebase. Nothing was run; a maintainer decides.

**Recommendation: Approve.** The code is ready: only testing is left. The synthetic tests show the hook return is corrected, but the target behavior has not yet been exercised with a real mod in the game, and build cost remains unmeasured. Recommend approval; not approved on the forge. The builder converts a safe branch back from a mod hook into a return, preventing the caller’s epilogue from running twice. It adds build-time code and patch-alternative analysis. **Testing before merging (2)** (runs on the systems it can change; it doesn't hold the recommendation) - **L3** `builder/crates/game-files/src/returns.rs:328`: The target behavior has not yet been exercised with a real hook that branches back. *When:* The reported game run used trampoline hooks, so it never executed a return produced by this pass. **Do:** Build and play with a mod containing a BL hook that returns with B, checking the conversion note and the affected feature on Windows and Linux. - **L4** `builder/crates/game-files/src/patches.rs:553`: The build cost of scanning code and patch alternatives has not been measured. *When:* A build with code patches now scans the code range and analyzes alternate writes; players wait for this work during the build. **Do:** Measure clean and incremental build time and output size against the base with representative code mods, as the builder standards require. **Since the last review** (on ad93385051f6) Still open: L3 (The target behavior has not yet been exercised with a real hook that branches back.); L4 (The build cost of scanning code and patch alternatives has not been measured.) **Checks:** they run again on this head; a failure shows on the pull request. <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Unproven in a real game hook. The reported synthetic tests changed from 18 failures to 20 passes in game-files, and both relevant driver tests passed after failing before the fix; no tested game mod used the branch-back pattern. **Other systems:** The pass affects builds on Windows and Linux and switch-dependent patch states. The reported Windows game run exercised trampoline mods, while the target branch-back hook and build cost remain untested. **Switches:** No switches added, changed or removed. Existing mod switch states are considered by the analysis. **Reviewed:** bdcac619bf1d against 3145d9d48f05: Read the repository rules and PR template, the commit list and diff summary, and the return pass and patch integration diff. The remaining changed files, tests and supporting callers were not read in full in this re-check.; nothing run (a code review). **Checked and fine:** - The recorded synthetic tests cover the intended return behavior and multiple switch states. - The rebase leaves no changed lines within the pull request diff since the previous review. **Testing:** No commands that build or run tests were executed. The author reports 93 game-files tests and 11 driver tests passing, plus a Windows game run with trampoline mods; CI has not run on this head. **Overlaps and merge order:** #3216 changes the driver test helper signature; whichever PR merges second needs the reported two-line test adjustment. The PR was stacked on #3165, whose commit is no longer in this diff. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, after its rebase. Nothing was run; a maintainer decides.</sub>
HumanBean deleted branch mods/exefs-bl-return 2026-12-05 17:28:13 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!3166
No description provided.