GPU: unprotect guarded alias pages when their last tracker drops #3152

Open
reeledMarek wants to merge 1 commit from upstream-pr/3154 into main
reeledMarek commented 2026-11-26 10:27:31 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by reeledMarek on 2026-11-26T10:27:31Z.


Summary

  • Tracked::take_split calls guard_aliases, marking aliased virtual pages PAGE_READONLY and inserting them into Guards::protected even when no tracker holds those alias pages directly in Guards::holders.
  • Tracked::drop in crates/victory-gpu/src/watch.rs previously only called open(&mut g, page) for the dropped tracker's own pages and never opened their aliases, leaving alias pages permanently PAGE_READONLY and stranded in Guards::protected after all trackers watching them or their aliases are dropped.
  • When a freed page is no longer watched through any alias, also open each of its alias pages that has no remaining holder and no watched alias.
  • Add Windows regression test dropping_the_last_tracker_unprotects_guarded_aliases verifying both Guards::protected cleanup and PAGE_READWRITE restoration.
<!-- greyfinch-sync:Marvisak/VIctory:issue:5508287290 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3154). Originally posted by [reeledMarek](https://github.com/reeledMarek) on 2026-11-26T10:27:31Z. --- ## Summary - `Tracked::take_split` calls `guard_aliases`, marking aliased virtual pages `PAGE_READONLY` and inserting them into `Guards::protected` even when no tracker holds those alias pages directly in `Guards::holders`. - `Tracked::drop` in `crates/victory-gpu/src/watch.rs` previously only called `open(&mut g, page)` for the dropped tracker's own pages and never opened their aliases, leaving alias pages permanently `PAGE_READONLY` and stranded in `Guards::protected` after all trackers watching them or their aliases are dropped. - When a freed page is no longer watched through any alias, also open each of its alias pages that has no remaining holder and no watched alias. - Add Windows regression test `dropping_the_last_tracker_unprotects_guarded_aliases` verifying both `Guards::protected` cleanup and `PAGE_READWRITE` restoration.
Dukestar69 commented 2026-11-26 11:29:33 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T11:29:33Z.

Review: APPROVED


Verified against origin/main (63bcca4):

  • cargo test -p victory-gpu --lib watch:: -- --test-threads=1: 16/16 passed (including dropping_the_last_tracker_unprotects_guarded_aliases).
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Cleanly unprotects guarded alias pages when their last tracker is dropped.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6073380385 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3154#pullrequestreview-6073380385). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T11:29:33Z. **Review:** APPROVED --- Verified against `origin/main` (`63bcca4`): - `cargo test -p victory-gpu --lib watch:: -- --test-threads=1`: 16/16 passed (including `dropping_the_last_tracker_unprotects_guarded_aliases`). - `cargo clippy -p victory-gpu --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Cleanly unprotects guarded alias pages when their last tracker is dropped. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
cloph-dsp commented 2026-11-26 12:05:56 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-26T11:25:20Z.


Independent local verification of head 079d9e2 on Windows 11, Rust 1.100.0/MSVC:

  • cargo test --locked -p victory-gpu --lib dropping_the_last_tracker_unprotects_guarded_aliases — 1 passed, 0 failed.
  • git diff --check origin/main HEAD — clean.

CPU-only guarded-alias test; no D3D12 device or game assets used. Worktree-local CARGO_TARGET_DIR. AI-assisted (Hy4 flash). GPU/driver: N/A (CPU-only). No game data.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7190704669 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3154#issuecomment-7190704669). Originally posted by [cloph-dsp](https://github.com/cloph-dsp) on 2026-11-26T11:25:20Z. --- Independent local verification of head `079d9e2` on Windows 11, Rust 1.100.0/MSVC: - `cargo test --locked -p victory-gpu --lib dropping_the_last_tracker_unprotects_guarded_aliases` — 1 passed, 0 failed. - `git diff --check origin/main HEAD` — clean. CPU-only guarded-alias test; no D3D12 device or game assets used. Worktree-local `CARGO_TARGET_DIR`. AI-assisted (Hy4 flash). GPU/driver: N/A (CPU-only). No game data.
futurepro62 commented 2026-11-26 21:34:15 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by futurepro62 on 2026-11-26T21:34:15Z.


NVIDIA full-suite run, to go with the reports above by Dukestar69, cloph-dsp, since none of them names a GPU run. Tested exact head 079d9e2 (on its base 63bcca4).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), dxil.dll from Windows SDK 10.0.26100 (the loader's default), debug.
  • cargo build --workspace --locked, then cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 867 passed, 0 failed, 10 ignored.
  • The new tests ran and passed: dropping_the_last_tracker_unprotects_guarded_aliases.
  • --skip leaves out tests that fail on main 63bcca4 on this card too, not because of this PR: heap_direct_texture_reads_mark_their_heap_index ends the victory-shader test process with 0xc0000005 (#2571), so without the skip the rest of that crate never reports; dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views and the two stride_tests hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); gathers_at_a_level_match_the_hardware fails on lane 0 (#1744).

Not tested

  • AMD (the tests take the default adapter), a release build, the title (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7203852640 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3154#issuecomment-7203852640). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-26T21:34:15Z. --- NVIDIA full-suite run, to go with the reports above by Dukestar69, cloph-dsp, since none of them names a GPU run. Tested exact head `079d9e2` (on its base `63bcca4`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), `dxil.dll` from Windows SDK 10.0.26100 (the loader's default), debug. - `cargo build --workspace --locked`, then `cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware`: **867 passed, 0 failed, 10 ignored**. - The new tests ran and passed: `dropping_the_last_tracker_unprotects_guarded_aliases`. - `--skip` leaves out tests that fail on main `63bcca4` on this card too, not because of this PR: `heap_direct_texture_reads_mark_their_heap_index` ends the `victory-shader` test process with `0xc0000005` (#2571), so without the skip the rest of that crate never reports; `dynamic_slots_are_held_until_released`, `lists_share_a_table_and_copies_keep_their_views` and the two `stride_tests` hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); `gathers_at_a_level_match_the_hardware` fails on lane 0 (#1744). **Not tested** - AMD (the tests take the default adapter), a release build, the title (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
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/3154:upstream-pr/3154'
git switch 'upstream-pr/3154'

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/3154'
git switch 'upstream-pr/3154'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3154'
git switch 'upstream-pr/3154'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3154'
git switch 'main'
git merge --squash 'upstream-pr/3154'
git switch 'main'
git merge --ff-only 'upstream-pr/3154'
git switch 'main'
git merge 'upstream-pr/3154'
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
Marvisak/VIctory!3152
No description provided.