Renderer port 2: a marked heap that goes takes its fallback pages with it (stale pages became inverted ranges) #273

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

@⁠sharan104 on GitHub · 2026-11-26 14:03 UTC · original
sharan104:fix/root-audit → main · +35 −0 · 1 files · 1 commits · open

With VICTORY_PORT_DESCRIPTORS=1 (renderer port 2, off by default; reporters use it, e.g. #240), port_descriptors::let_go dropped the marked view heap but left the fallback's page set full. These are the write-watch pages asked() gathered for the old heap. When the next shader-visible view heap is adopted, to_check keeps handing out the old heap's pages. sync_heaps (descriptor.rs) clamps each one to the new heap, so a page outside it becomes a range that ends before it begins:

  • Debug builds: changed_slots underflows and panics.
  • VICTORY_SYNC_IN_PLACE=0: page_bytes.resize(to - from) asks for nearly usize::MAX bytes, which panics in release too.
  • The default in-place path in release: it only corrupts counters.

Whether the title ever drops and recreates that heap is unknown without the game. When it does, these are the outcomes.

Fix: let_go also clears the fallback's pages and resets where it resumes (next). It takes FALLBACK while holding the ADOPTED write lock. No path takes them in the other order: ask_due, asked and to_check never touch ADOPTED.

Test: a_heap_that_goes_leaves_no_pages_to_check adopts a heap, reports two of its pages, lets it go and adopts another. Before the fix, to_check returned the old heap's two pages. Now it returns none, and a page of the new heap still comes back. A small test lock (one_heap) makes the two heap tests take turns, since the marked heap is one per process. The new test fails before the fix and passed 10 runs out of 10 after it.

Results:

  • cargo test -p victory-gpu --locked: 382 passed, 0 failed, 34 ignored.
  • Clippy -D warnings, with and without --all-features, is clean apart from main's existing unnecessary_mut_passed in watch.rs, which #241 fixes.

🤖 Generated with Claude Code

**@⁠sharan104** on GitHub · 2026-11-26 14:03 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/273) `sharan104:fix/root-audit` → `main` · +35 −0 · 1 files · 1 commits · open With `VICTORY_PORT_DESCRIPTORS=1` (renderer port 2, off by default; reporters use it, e.g. #240), `port_descriptors::let_go` dropped the marked view heap but left the fallback's page set full. These are the write-watch pages `asked()` gathered for the old heap. When the next shader-visible view heap is adopted, `to_check` keeps handing out the old heap's pages. `sync_heaps` (`descriptor.rs`) clamps each one to the new heap, so a page outside it becomes a range that ends before it begins: - **Debug builds:** `changed_slots` underflows and panics. - **`VICTORY_SYNC_IN_PLACE=0`:** `page_bytes.resize(to - from)` asks for nearly `usize::MAX` bytes, which panics in release too. - **The default in-place path in release:** it only corrupts counters. Whether the title ever drops and recreates that heap is unknown without the game. When it does, these are the outcomes. **Fix:** `let_go` also clears the fallback's pages and resets where it resumes (`next`). It takes `FALLBACK` while holding the `ADOPTED` write lock. No path takes them in the other order: `ask_due`, `asked` and `to_check` never touch `ADOPTED`. **Test:** `a_heap_that_goes_leaves_no_pages_to_check` adopts a heap, reports two of its pages, lets it go and adopts another. Before the fix, `to_check` returned the old heap's two pages. Now it returns none, and a page of the new heap still comes back. A small test lock (`one_heap`) makes the two heap tests take turns, since the marked heap is one per process. The new test fails before the fix and passed 10 runs out of 10 after it. **Results:** - `cargo test -p victory-gpu --locked`: 382 passed, 0 failed, 34 ignored. - Clippy `-D warnings`, with and without `--all-features`, is clean apart from main's existing `unnecessary_mut_passed` in `watch.rs`, which #241 fixes. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The fallback's pages (the write watch's pages of the marked view heap,
looked at whole a few a frame) are kept in one global set, and nothing
emptied it when the heap went. With VICTORY_PORT_DESCRIPTORS=1, the next
placed shader-visible view heap is adopted in its place, and to_check went
on handing out the old heap's pages for it. sync_heaps clamps each page to
the new heap, so a page outside it became a range that ends before it
begins: changed_slots and the byte count underflow (a panic in debug
builds), and with VICTORY_SYNC_IN_PLACE=0 page_bytes.resize(to - from)
asks for nearly usize::MAX bytes.

let_go now empties the fallback's pages (and where it goes on from) with
the heap. The test adopts a heap, has the watch tell of two of its pages,
lets it go and adopts another: before the fix to_check returned the old
heap's two pages, now none, and a page of the new heap still comes back.
The module's two heap tests take turns on a lock, as the marked heap is
one for the process.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 14:06:53 +00:00
Author
Owner

@⁠lerapeurdu62280-debug on GitHub · 2026-11-26 14:16 UTC · original · approved these changes

Read the diff. Clearing the fallback's pages and next in let_go fixes the stale-page inverted ranges, the FALLBACK-under-ADOPTED lock order holds (ask_due/asked/to_check never take ADOPTED), and the new test fails without the fix.

**@⁠lerapeurdu62280-debug** on GitHub · 2026-11-26 14:16 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/273#pullrequestreview-6075636360) · **approved these changes** Read the diff. Clearing the fallback's pages and next in let_go fixes the stale-page inverted ranges, the FALLBACK-under-ADOPTED lock order holds (ask_due/asked/to_check never take ADOPTED), and the new test fails without the fix.
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/port_descriptors.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

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

Merge

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