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

Open
sharan104 wants to merge 1 commit from upstream-pr/273 into main
sharan104 commented 2026-11-26 14:03:11 +00:00 (Migrated from github.com)

Imported from avatarmanz/VIctory-7900XTX. Originally posted by sharan104 on 2026-11-26T14:03:11Z.


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

<!-- greyfinch-sync:avatarmanz/VIctory-7900XTX:issue:6628315448 --> Imported from [avatarmanz/VIctory-7900XTX](https://github.com/avatarmanz/VIctory-7900XTX/pull/273). Originally posted by [sharan104](https://github.com/sharan104) on 2026-11-26T14:03:11Z. --- 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)
lerapeurdu62280-debug commented 2026-11-26 14:16:05 +00:00 (Migrated from github.com)

Imported from avatarmanz/VIctory-7900XTX. Originally posted by lerapeurdu62280-debug on 2026-11-26T14:16:05Z.


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.

<!-- greyfinch-sync:avatarmanz/VIctory-7900XTX:review:6075636360 --> Imported from [avatarmanz/VIctory-7900XTX](https://github.com/avatarmanz/VIctory-7900XTX/pull/273#pullrequestreview-6075636360). Originally posted by [lerapeurdu62280-debug](https://github.com/lerapeurdu62280-debug) on 2026-11-26T14:16:05Z. --- 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 cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/273:upstream-pr/273'
git switch 'upstream-pr/273'

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.

git switch 'main'
git merge --no-ff 'upstream-pr/273'
git switch 'upstream-pr/273'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/273'
git switch 'upstream-pr/273'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/273'
git switch 'main'
git merge --squash 'upstream-pr/273'
git switch 'main'
git merge --ff-only 'upstream-pr/273'
git switch 'main'
git merge 'upstream-pr/273'
git push origin 'main'
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
avatarmanz/VIctory-7900XTX!273
No description provided.