fix: let the texture table go before slot_evict takes it again #328

Open
github-bot wants to merge 1 commit from github-bot/gh-328 into main AGit
Owner

@⁠Skyfrye on GitHub · 2026-11-26 03:31 UTC · original
Skyfrye:nep/slot-evict-deadlock → main · +3 −0 · 1 files · 1 commits · open

Change

resource::let_go_idle takes the table of all textures (let all = textures();), sweeps it, and then calls slot_evict with all still held. slot_evict takes the same table again (for &at in textures().iter()). TEXTURES is a std::sync::Mutex, which is not reentrant: the second lock on the submitting thread waits for itself for good. From then on every title thread that makes or releases a resource waits for that table too, and the title ends.

slot_evict only gets that far with VICTORY_SLOT_EVICT=1 and the card's use over VICTORY_SLOT_EVICT_PERCENT (80) of its budget, which in the world is the moment it enters it. Before that it returns early, which is why the switch seemed to work in short runs.

The fix: drop(all) before the call. slot_evict already does its own lookups under its own lock of the table.

Linked issue: none.

Verification

Windows 11 26300, Rust 1.98.1 (MSVC), RTX 5080, on upstream main at c4c93bd, from third_party/victory:

cargo build --locked --release -p victory   -> Finished, no new warning

In the world, my copy of the game, launcher fast set with VICTORY_INDIRECT_RAW=3, runs of 150-240 s:

Build Switches Runs The title ended
without this change VICTORY_SLOT_EVICT=1 9 9: unhandled exception 0xc0000005 ... (write 0x0: nothing mapped there) in the title, 0.5-1 min after it entered the world, the same instruction every time
without this change VICTORY_SLOT_EVICT=1, VICTORY_SLOT_EVICT_PERCENT=97 (the line never reached) 1 0
without this change no VICTORY_SLOT_EVICT 9 0
with this change VICTORY_SLOT_EVICT=1 2 0; 107 and 112 sweeps, 23 and 12 host copies let go with their slots (15 and 13 MB), 557 and 59 slots reset, 10 copies came back (none within 2 s); 16.9 and 17.1 fps

How it was found: a build with a line logged at each step of slot_evict never logged one in the runs that ended (the first textures() of the function never returned), while the same runs with the line out of reach (97 %) ran on; reading let_go_idle showed the held guard.

No test: the deadlock needs the card's budget over the line and textures made through the device. The revert check is the table above.

What this does not do: make VICTORY_SLOT_EVICT free much. In these runs 3.8 GB of host copies were "filled idle but held" and it let 13-15 MB go: most of them are held by slots that shaders pick by index, which slot_evict leaves alone (nothing would make them again). That is a change of its own.

Oracle and test data

No game file. The counts come from my own runs of my copy of the game; the instruction is named by its module offset only in my notes, not here.

Checklist

  • The PR covers a single reviewable behaviour (the texture table is let go before slot_evict takes it).
  • A test fails without this change and passes with it. — No: see above; the in-game table is the check.
  • The commands and results of each check are given above.
  • An unimplemented function returns an error (E_NOTIMPL), never a fake success. (Nothing unimplemented here.)
  • README: not touched.
  • No game, console or SDK file, no key, no dump, no download link.
  • Findings drawn from a title: that the title ends, and when; no title code.
  • Code taken from another project: none.

AI assistance: written with Claude Code. Claude Opus 5.5 ran the crash runs and the step-by-step test builds, found the held guard, and wrote this description.

🤖 Generated with Claude Code

**@⁠Skyfrye** on GitHub · 2026-11-26 03:31 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/328) `Skyfrye:nep/slot-evict-deadlock` → `main` · +3 −0 · 1 files · 1 commits · open ## Change `resource::let_go_idle` takes the table of all textures (`let all = textures();`), sweeps it, and then calls `slot_evict` with `all` still held. `slot_evict` takes the same table again (`for &at in textures().iter()`). `TEXTURES` is a `std::sync::Mutex`, which is not reentrant: the second lock on the submitting thread waits for itself for good. From then on every title thread that makes or releases a resource waits for that table too, and the title ends. `slot_evict` only gets that far with `VICTORY_SLOT_EVICT=1` and the card's use over `VICTORY_SLOT_EVICT_PERCENT` (80) of its budget, which in the world is the moment it enters it. Before that it returns early, which is why the switch seemed to work in short runs. The fix: `drop(all)` before the call. `slot_evict` already does its own lookups under its own lock of the table. Linked issue: none. ## Verification Windows 11 26300, Rust 1.98.1 (MSVC), RTX 5080, on upstream `main` at `c4c93bd`, from `third_party/victory`: ``` cargo build --locked --release -p victory -> Finished, no new warning ``` In the world, my copy of the game, launcher fast set with `VICTORY_INDIRECT_RAW=3`, runs of 150-240 s: | Build | Switches | Runs | The title ended | |---|---|---|---| | without this change | `VICTORY_SLOT_EVICT=1` | 9 | 9: `unhandled exception 0xc0000005 ... (write 0x0: nothing mapped there)` in the title, 0.5-1 min after it entered the world, the same instruction every time | | without this change | `VICTORY_SLOT_EVICT=1`, `VICTORY_SLOT_EVICT_PERCENT=97` (the line never reached) | 1 | 0 | | without this change | no `VICTORY_SLOT_EVICT` | 9 | 0 | | with this change | `VICTORY_SLOT_EVICT=1` | 2 | 0; 107 and 112 sweeps, 23 and 12 host copies let go with their slots (15 and 13 MB), 557 and 59 slots reset, 10 copies came back (none within 2 s); 16.9 and 17.1 fps | How it was found: a build with a line logged at each step of `slot_evict` never logged one in the runs that ended (the first `textures()` of the function never returned), while the same runs with the line out of reach (97 %) ran on; reading `let_go_idle` showed the held guard. No test: the deadlock needs the card's budget over the line and textures made through the device. The revert check is the table above. What this does not do: make `VICTORY_SLOT_EVICT` free much. In these runs 3.8 GB of host copies were "filled idle but held" and it let 13-15 MB go: most of them are held by slots that shaders pick by index, which `slot_evict` leaves alone (nothing would make them again). That is a change of its own. ## Oracle and test data No game file. The counts come from my own runs of my copy of the game; the instruction is named by its module offset only in my notes, not here. ## Checklist - [x] The PR covers a single reviewable behaviour (the texture table is let go before `slot_evict` takes it). - [ ] A test fails without this change and passes with it. — No: see above; the in-game table is the check. - [x] The commands and results of each check are given above. - [x] An unimplemented function returns an error (`E_NOTIMPL`), never a fake success. (Nothing unimplemented here.) - [x] README: not touched. - [x] No game, console or SDK file, no key, no dump, no download link. - [x] Findings drawn from a title: that the title ends, and when; no title code. - [x] Code taken from another project: none. AI assistance: written with Claude Code. Claude Opus 5.5 ran the crash runs and the step-by-step test builds, found the held guard, and wrote this description. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
let_go_idle held the table of all textures when it called slot_evict,
which locks the same std::sync::Mutex again: on the submitting thread
that waits for itself for good, every title thread that makes or
releases a resource waits behind it, and the title ends. It happens
once the card's use passes VICTORY_SLOT_EVICT_PERCENT with
VICTORY_SLOT_EVICT=1: in the world 9 of 9 runs ended so, 0 of 2 with
this change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:43:14 +00:00
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/328/head:github-bot/gh-328'
git switch 'github-bot/gh-328'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-328'
git switch 'github-bot/gh-328'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-328'
git switch 'github-bot/gh-328'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-328'
git switch 'main'
git merge --squash 'github-bot/gh-328'
git switch 'main'
git merge --ff-only 'github-bot/gh-328'
git switch 'main'
git merge 'github-bot/gh-328'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.