loader: VICTORY_LOOKUP_EXIT gives the title's object lookup a not-found exit (#456) #565
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/565"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by maaalrey on 2026-11-28T05:18:51Z.
What this changes
Refs #456.
Adds
VICTORY_LOOKUP_EXIT=1, off by default: a way out of the title lookup that the stuck threads of #456 sit in.native::lookup_exit::armturns the first byte of the loop's "not in this group, try the next" path (image+0x50eb9d1) into anint3before any title code runs.on_breakpoint, called first in the exception dispatch, then does what that path did, or, when the group just searched has an empty control byte (0x80), setsripto the function's own epilogue (image+0x50eb910), which the function already takes for an object with nothing to draw.It does not fix the cause: what orders the free behind the lookups on the console is still unknown. As I read it, a freed object is skipped for that frame. I have not checked what else the early return skips, and I have not compared pictures.
The offsets are for the one build we test, like
VICTORY_HOLD_BYTE's address.How it was tested
cargo test --target x86_64-apple-darwin -p victory-hle -p victory-loader -p victory(and-p xtask): all pass. Eight new tests innative::lookup_exit, among themthe_patch_changes_one_byte_and_keeps_the_pages_protection(on a stand-in page),a_missing_key_leaves_the_loop_at_the_first_group_with_an_empty_entryandnothing_is_handled_before_the_patch_is_in.cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warningscargo xtask policyvictory-gputests (#548; this change does not touch that crate).All on main
2f4d81e0, with one local change for the runs only (the sound output replaced by the silent one):VICTORY_LOOKUP_EXITThe first two rows are four pairs, alternating. With this commit the log has
VICTORY_LOOKUP_EXIT: armedand, in three of the four runs, the exit lines: at least 8 exits each (the log prints the first eight, then powers of two), every handle a pool-4 handle with generation 2, after 19 to 151 steps to a next group; in the fourth run no lookup needed the exit. The world started 105 to 192 s into those runs and ran at 1.3 to 1.6 fps mean to the end of the run. The stuck runs go quiet after 76 to 78 thousand DirectStorage requests, as in #456.Before the rewrite for this branch, the same idea as a local experiment on main
8efcff13: 0 of 10 runs stuck with it against 4 of 4 without, and one new-game run of 480 s reached the world and never took the exit (numbers in #456).Checklist
VICTORY_*variable and documentedImported from LakshanSivakumar/Native-Victory-macOS. Originally posted by derz92 on 2026-11-28T06:16:09Z.
Independent test of this on another Mac: it rescues the #456 freeze here.
Setup: M5 Max, macOS 26.5, Series S, warm cache. This commit on
lit-world/base-3plus local speed changes, #437's switches. To make the race more frequent, both arms also ran withVICTORY_SKIP_PIPELINES=6a04b371a8e26853,7de0f9db96ddd295, which raised the freeze rate here to about 3 in 4 (data on #456). One binary, alternating on and off, 200 s world cap.VICTORY_LOOKUP_EXITsteps=313each). That was at about 71 s, frame ~1500, exactly where the freezes happen here. The run then kept presenting to its cap (frames 1832–1884).I'm keeping it on for play here. Thanks for this.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by maaalrey on 2026-11-28T06:27:13Z.
Thank you for running it. Good to know the exits come on the new-game path too, at the same frames where it froze for you without it: so that freeze and the one I get loading a save look like the same thing.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AnastasisKon on 2026-11-28T18:14:22Z.
Review: APPROVED
Reviewed and verified locally on head
03bf3367(worktree /private/tmp/review-565):The patch discipline is right for a build-specific hook: the seven bytes at image+0x50eb9d1 are verified to be + near jump to the loop head before anything is written, only one byte becomes int3, the page gets its old protection back and the icache is flushed, and arm() runs before any title thread so Rosetta translates the patched bytes. on_breakpoint costs one atomic load when not armed and is called first in dispatch. The guesses (empty control byte 0x80 ends the probe; free-ahead ordering is timing) are documented in the module docs and native-host.md, and the PR honestly says it does not fix the cause and has not compared pictures — appropriate for an off-by-default diagnostic. The A/B game table (4/4 stuck without, 4/4 in the world with) is exactly the evidence this needs. Approving.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AnastasisKon on 2026-11-28T18:14:37Z.
Small clarification to my review above (a shell ate the inline code): the seven bytes at image+0x50eb9d1 are verified to be
inc eax(ff c0) followed by the near jump (e9) back to the loop head before anything is written.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.