GPU: keep untracked pages writable in Tracked::taken #3013

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

@⁠fuzeofficlal on GitHub · 2026-11-26 03:25 UTC · original
fuzeofficlal:fix/gpu-watch-taken-skip-untracked → main · +141 −3 · 1 files · 1 commits · open

Summary

  • Filter pages in crates/victory-gpu/src/watch.rs::Tracked::taken against g.holders for self.changed before calling aliases, guard_aliases, and protect, returning early if none of the pages belong to this tracker.
  • Fixes a page-protection leak when a Shadow buffer or 4 MiB loose window spans both MEM_WRITE_WATCH runtime pages and adjacent untracked/foreign committed pages: previously Shadow::copy_back, copy_back_page, and copy_back_marked called t.taken(...), which passed untracked pages to VirtualProtect(..., PAGE_READONLY) and inserted them into g.protected without a g.holders entry (leaving them permanently read-only even after Tracked::drop, and risking a VEH + heap-lock deadlock if a process-heap page is touched).
  • Add regression test watch::tests::taken_skips_untracked_and_foreign_pages covering both direct Tracked::taken on a mixed foreign/pool window and end-to-end Shadow::copy_back + Shadow::copy_back_page over adjacent pool and plain committed pages.

Verification

  • Regression check: watch::tests::taken_skips_untracked_and_foreign_pages fails on main (PAGE_READONLY instead of PAGE_READWRITE) and passes with the fix.
  • cargo test --locked -p victory-gpu watch::tests::: 16/16 passed on RTX 5090 (shadow::tests:: 9/9 passed).
  • VICTORY_D3D12_WARP=1 cargo test --locked -p victory-gpu --all-features: 247 passed, 0 failed, 1 ignored.
  • cargo clippy --locked -p victory-gpu --all-targets -- -D warnings (default and --all-features): 0 warnings.
  • cargo xtask policy: 191 files ok.
**@⁠fuzeofficlal** on GitHub · 2026-11-26 03:25 UTC · [original](https://github.com/Marvisak/VIctory/pull/3013) `fuzeofficlal:fix/gpu-watch-taken-skip-untracked` → `main` · +141 −3 · 1 files · 1 commits · open ## Summary - Filter `pages` in `crates/victory-gpu/src/watch.rs::Tracked::taken` against `g.holders` for `self.changed` before calling `aliases`, `guard_aliases`, and `protect`, returning early if none of the pages belong to this tracker. - Fixes a page-protection leak when a `Shadow` buffer or 4 MiB loose window spans both `MEM_WRITE_WATCH` runtime pages and adjacent untracked/foreign committed pages: previously `Shadow::copy_back`, `copy_back_page`, and `copy_back_marked` called `t.taken(...)`, which passed untracked pages to `VirtualProtect(..., PAGE_READONLY)` and inserted them into `g.protected` without a `g.holders` entry (leaving them permanently read-only even after `Tracked::drop`, and risking a VEH + heap-lock deadlock if a process-heap page is touched). - Add regression test `watch::tests::taken_skips_untracked_and_foreign_pages` covering both direct `Tracked::taken` on a mixed foreign/pool window and end-to-end `Shadow::copy_back` + `Shadow::copy_back_page` over adjacent pool and plain committed pages. ## Verification - Regression check: `watch::tests::taken_skips_untracked_and_foreign_pages` fails on `main` (`PAGE_READONLY` instead of `PAGE_READWRITE`) and passes with the fix. - `cargo test --locked -p victory-gpu watch::tests::`: 16/16 passed on RTX 5090 (`shadow::tests::` 9/9 passed). - `VICTORY_D3D12_WARP=1 cargo test --locked -p victory-gpu --all-features`: 247 passed, 0 failed, 1 ignored. - `cargo clippy --locked -p victory-gpu --all-targets -- -D warnings` (default and `--all-features`): 0 warnings. - `cargo xtask policy`: 191 files ok.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:20:05 +00:00
Author
Owner

@⁠pickles976 on GitHub · 2026-11-26 03:29 UTC · original

Exact PR head 0f2fb8c55b1a7c9814c5eeada6ee3de0cebf3d87, Windows-target Wine 11.0/vkd3d-proton 3.2.0 on a 16 GiB host with physical NVIDIA RTX 4060 Laptop GPU (8 GiB) (dxgi.hideNvidiaGpu = False): watch::tests::taken_skips_untracked_and_foreign_pages 1/1 passed, 0 ignored. Build log confirms Compiling victory-gpu from the clean PR checkout, and DXVK enumerated the laptop NVIDIA adapter. The regression exercises direct mixed owned/foreign pages and Shadow::copy_back/copy_back_page; it leaves foreign/plain pages PAGE_READWRITE while guarding only the tracked page. Local log: .compat-runtime/logs/verify-pr3013-wine-mixed-pages.log (not attached).

This is a useful Wine page-protection/liveness check, not a GPU command-dispatch or guarded title test; device enumeration does not mean this fixture rendered on the GPU. It does not resolve the separate 16 GiB world-load RAM floor, so no gameplay/FPS claim.

**@⁠pickles976** on GitHub · 2026-11-26 03:29 UTC · [original](https://github.com/Marvisak/VIctory/pull/3013#issuecomment-7181761510) Exact PR head `0f2fb8c55b1a7c9814c5eeada6ee3de0cebf3d87`, Windows-target Wine 11.0/vkd3d-proton 3.2.0 on a 16 GiB host with physical NVIDIA **RTX 4060 Laptop GPU (8 GiB)** (`dxgi.hideNvidiaGpu = False`): `watch::tests::taken_skips_untracked_and_foreign_pages` **1/1 passed**, 0 ignored. Build log confirms `Compiling victory-gpu` from the clean PR checkout, and DXVK enumerated the laptop NVIDIA adapter. The regression exercises direct mixed owned/foreign pages and `Shadow::copy_back`/`copy_back_page`; it leaves foreign/plain pages `PAGE_READWRITE` while guarding only the tracked page. Local log: `.compat-runtime/logs/verify-pr3013-wine-mixed-pages.log` (not attached). This is a useful Wine page-protection/liveness check, **not** a GPU command-dispatch or guarded title test; device enumeration does not mean this fixture rendered on the GPU. It does not resolve the separate 16 GiB world-load RAM floor, so no gameplay/FPS claim.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-26 06:17 UTC · original

Automated triage for the maintainers.

In main, Tracked::taken (victory-gpu/src/watch.rs) protects every page its caller passes in. Two callers can pass pages that this tracker never registered in g.holders:

  • Shadow::copy_back passes every synced page in range.
  • copy_back_page passes the page it wrote.

Such pages include foreign or plain committed memory inside a buffer or window. They get made PAGE_READONLY and added to g.protected, and Tracked::drop never unprotects them, because it only walks the tracker's own pages. The PR filters the pages down to those this tracker holds before the alias and protect steps. It keeps the existing lock order (guards first, then changed) and returns early when no pages are left. The new test covers direct taken calls and both Shadow copy-back paths over a mix of write-watched and plain pages.

This looks like a real fix for a latent leak of read-only protection onto memory the tracker doesn't own.

CI: check passing.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-26 06:17 UTC · [original](https://github.com/Marvisak/VIctory/pull/3013#issuecomment-7184289953) <!-- victory-triage v1 head=0f2fb8c55b1a7c9814c5eeada6ee3de0cebf3d87 verdict=merge-candidate at=2026-11-26T06:23:00Z --> Automated triage for the maintainers. In `main`, `Tracked::taken` (`victory-gpu/src/watch.rs`) protects every page its caller passes in. Two callers can pass pages that this tracker never registered in `g.holders`: - `Shadow::copy_back` passes every synced page in range. - `copy_back_page` passes the page it wrote. Such pages include foreign or plain committed memory inside a buffer or window. They get made `PAGE_READONLY` and added to `g.protected`, and `Tracked::drop` never unprotects them, because it only walks the tracker's own pages. The PR filters the pages down to those this tracker holds before the alias and `protect` steps. It keeps the existing lock order (guards first, then `changed`) and returns early when no pages are left. The new test covers direct `taken` calls and both `Shadow` copy-back paths over a mix of write-watched and plain pages. This looks like a real fix for a latent leak of read-only protection onto memory the tracker doesn't own. CI: `check` passing. --- _Generated by [Claude Code](https://claude.ai/code)_
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/3013/head:github-bot/gh-3013'
git switch 'github-bot/gh-3013'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3013'
git switch 'github-bot/gh-3013'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3013'
git switch 'github-bot/gh-3013'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3013'
git switch 'main'
git merge --squash 'github-bot/gh-3013'
git switch 'main'
git merge --ff-only 'github-bot/gh-3013'
git switch 'main'
git merge 'github-bot/gh-3013'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!3013
No description provided.