Watch: dropping a tracker keeps a mapping guarded while a tracker holds its alias #2238

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

@⁠denkencar-sketch on GitHub · 2026-11-25 08:31 UTC · original
denkencar-sketch:fix/watch-alias-drop → main · +32 −3 · 1 files · 1 commits · open

Summary

When a tracker is dropped, Drop for Tracked opens (PAGE_READWRITE) every page that no tracker holds any more. That includes a page which guard_aliases guarded for a tracker of another mapping of the same memory. A write through the opened mapping then goes unseen, and the other tracker's take() finds nothing changed (it returns early when its changed set is empty, before it could guard the alias again).

The other direction is a stale guard: when the last tracker goes, aliases that only guard_aliases had guarded stay read-only until a write faults.

Change

A page stays guarded while a tracker holds it or a page showing the same memory (watched). When a page is freed, it and its aliases are opened only if nothing watches them any more.

Testing

Two tests on two views of one section (twin_views), both failing on main:

  • a_tracker_dropped_leaves_the_other_mapping_guarded: trackers on both views, both taken, drop the first, write through the first view: the second tracker's take must see the page (on main it returns nothing).
  • dropping_the_last_tracker_opens_both_mappings: after the only tracker is dropped, neither page is left in protected.

The suite passed three times in a row. cargo clippy --workspace --all-targets [--all-features] --locked -- -D warnings is clean.

Not tried: a run in the game. modules::dstorage::tests::a_page_list_filled_after_its_request_starts fails now and then on main too (5 of 20 runs of cargo test -p victory-hle --lib); it is unrelated.

AI-assisted.

**@⁠denkencar-sketch** on GitHub · 2026-11-25 08:31 UTC · [original](https://github.com/Marvisak/VIctory/pull/2238) `denkencar-sketch:fix/watch-alias-drop` → `main` · +32 −3 · 1 files · 1 commits · open ## Summary When a tracker is dropped, `Drop for Tracked` opens (`PAGE_READWRITE`) every page that no tracker holds any more. That includes a page which `guard_aliases` guarded for a tracker of another mapping of the same memory. A write through the opened mapping then goes unseen, and the other tracker's `take()` finds nothing changed (it returns early when its changed set is empty, before it could guard the alias again). The other direction is a stale guard: when the last tracker goes, aliases that only `guard_aliases` had guarded stay read-only until a write faults. ## Change A page stays guarded while a tracker holds it or a page showing the same memory (`watched`). When a page is freed, it and its aliases are opened only if nothing watches them any more. ## Testing Two tests on two views of one section (`twin_views`), both failing on `main`: - `a_tracker_dropped_leaves_the_other_mapping_guarded`: trackers on both views, both taken, drop the first, write through the first view: the second tracker's `take` must see the page (on `main` it returns nothing). - `dropping_the_last_tracker_opens_both_mappings`: after the only tracker is dropped, neither page is left in `protected`. The suite passed three times in a row. `cargo clippy --workspace --all-targets [--all-features] --locked -- -D warnings` is clean. Not tried: a run in the game. `modules::dstorage::tests::a_page_list_filled_after_its_request_starts` fails now and then on `main` too (5 of 20 runs of `cargo test -p victory-hle --lib`); it is unrelated. AI-assisted.
main already keeps a dropped page guarded while a tracker holds its alias. When the last tracker on any mapping drops, the other mappings that guard_aliases guarded still stayed read-only in protected until a write faulted. Drop now opens those unwatched aliases too.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:59:32 +00:00
Author
Owner

@⁠MamaLeVrai on GitHub · 2026-11-25 09:13 UTC · original

Test report on real hardware: AMD RX 6950 XT (RDNA2), Windows 11, Rust 1.98.1, with a GPU present, so the hardware-only shader checks run. I merged this PR's head 6d86640a into main 940d32f in a throwaway tree (no conflict). cargo clippy --workspace --all-targets --locked -- -D warnings: clean; the same with --all-features: clean. cargo test --workspace --locked: 703 passed, 0 failed, 10 ignored, two runs (main alone on the same machine: 701 passed, 0 failed, 10 ignored). The title was not run, so this says nothing about in-game effect. No game data.

AI-assisted (Claude Code); no game data.

**@⁠MamaLeVrai** on GitHub · 2026-11-25 09:13 UTC · [original](https://github.com/Marvisak/VIctory/pull/2238#issuecomment-7158043732) Test report on real hardware: AMD RX 6950 XT (RDNA2), Windows 11, Rust 1.98.1, with a GPU present, so the hardware-only shader checks run. I merged this PR's head `6d86640a` into `main` `940d32f` in a throwaway tree (no conflict). `cargo clippy --workspace --all-targets --locked -- -D warnings`: clean; the same with `--all-features`: clean. `cargo test --workspace --locked`: 703 passed, 0 failed, 10 ignored, two runs (`main` alone on the same machine: 701 passed, 0 failed, 10 ignored). The title was not run, so this says nothing about in-game effect. No game data. AI-assisted (Claude Code); no game data.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 13:30 UTC · original · edited 2026-11-26 00:22 UTC

Automated triage for the maintainers.

Merge candidate (worth a look). After the rebase, main already keeps a dropped page guarded while a tracker holds one of its aliases. What this adds, in Drop for Tracked (crates/victory-gpu/src/watch.rs), is the other half: when the last tracker on a page goes, its aliases (guarded by guard_aliases when the page was taken) are opened too, unless another tracker still holds them or one of their own aliases (watched). Without it those alias pages stay read-only with no tracker left. The test dropping_the_last_tracker_opens_both_mappings covers it. CI check passes and it merges cleanly.

On your reply: confirmed. The part already in main is gone from the diff, and what remains is the alias opening and its test.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 13:30 UTC · [original](https://github.com/Marvisak/VIctory/pull/2238#issuecomment-7163876360) · edited 2026-11-26 00:22 UTC <!-- victory-triage v1 head=0c21a73bf5dcc09678ec1fabecd585811788f0f4 verdict=merge-candidate at=2026-11-26T00:22:58Z --> Automated triage for the maintainers. **Merge candidate (worth a look).** After the rebase, `main` already keeps a dropped page guarded while a tracker holds one of its aliases. What this adds, in `Drop for Tracked` (`crates/victory-gpu/src/watch.rs`), is the other half: when the last tracker on a page goes, its aliases (guarded by `guard_aliases` when the page was taken) are opened too, unless another tracker still holds them or one of their own aliases (`watched`). Without it those alias pages stay read-only with no tracker left. The test `dropping_the_last_tracker_opens_both_mappings` covers it. CI `check` passes and it merges cleanly. On your reply: confirmed. The part already in `main` is gone from the diff, and what remains is the alias opening and its test. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠denkencar-sketch on GitHub · 2026-11-25 23:17 UTC · original

Rebased onto current \main\ (\842b0cb). \main\ now already keeps the dropped page guarded while an alias is held; this rebased commit keeps the remaining part (opening unwatched aliases in \protected\ when the last tracker drops) and its test. \watch::tests\ (16/16) and \clippy\ pass.

**@⁠denkencar-sketch** on GitHub · 2026-11-25 23:17 UTC · [original](https://github.com/Marvisak/VIctory/pull/2238#issuecomment-7177360291) Rebased onto current \main\ (\842b0cb\). \main\ now already keeps the dropped page guarded while an alias is held; this rebased commit keeps the remaining part (opening unwatched aliases in \protected\ when the last tracker drops) and its test. \watch::tests\ (16/16) and \clippy\ pass.
Author
Owner

@⁠DenRakEiw on GitHub · 2026-11-25 08:42 UTC · original · approved these changes

Verified locally merged onto origin/main (940d32f, Windows 11 x64, Rust 1.98.1 MSVC):

  • cargo test -p victory-gpu --lib watch:: — 8 passed, 0 failed (including a_tracker_dropped_leaves_the_other_mapping_guarded and dropping_the_last_tracker_opens_both_mappings)
  • cargo clippy -p victory-gpu --all-targets — 0 warnings
  • cargo xtask policy — ok (183 files ok)

Clean alias-aware guard retention when dropping a tracker whose alias is still tracked. Looks good.

AI-assisted (Gemini 4 Neon).

**@⁠DenRakEiw** on GitHub · 2026-11-25 08:42 UTC · [original](https://github.com/Marvisak/VIctory/pull/2238#pullrequestreview-6054309048) · **approved these changes** Verified locally merged onto `origin/main` (`940d32f`, Windows 11 x64, Rust 1.98.1 MSVC): - `cargo test -p victory-gpu --lib watch::` — **8 passed, 0 failed** (including `a_tracker_dropped_leaves_the_other_mapping_guarded` and `dropping_the_last_tracker_opens_both_mappings`) - `cargo clippy -p victory-gpu --all-targets` — 0 warnings - `cargo xtask policy` — ok (`183 files ok`) Clean alias-aware guard retention when dropping a tracker whose alias is still tracked. Looks good. AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠catminou4 on GitHub · 2026-11-25 08:48 UTC · original · reviewed

Watch: dropping a tracker keeps a mapping guarded while another tracker holds aliases of the same pages (watched check over alias_of). Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1. Same cluster; fixes alias guard lifetime.

**@⁠catminou4** on GitHub · 2026-11-25 08:48 UTC · [original](https://github.com/Marvisak/VIctory/pull/2238#pullrequestreview-6054381282) · **reviewed** Watch: dropping a tracker keeps a mapping guarded while another tracker holds aliases of the same pages (`watched` check over alias_of). Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1. Same cluster; fixes alias guard lifetime.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 19:44 UTC · original · approved these changes

Reviewed and verified 0c21a73bf5dcc09678ec1fabecd585811788f0f4 merged onto origin/main (63bcca43c6a00a758510398fa43096ce7e4f7df0) on Windows 11 x64 (RTX 5090 + Microsoft WARP, --features diagnostics, Rust 1.98.1 MSVC).

Code Audit

  • In Drop for Tracked (crates/victory-gpu/src/watch.rs:436-453), once a page leaves g.holders, iterating std::iter::once(page).chain(others) and calling open(&mut g, p) only when !watched(&g, p) handles both invariants under the single guards() lock (no additional locks or lock-order changes):
    • While any tracker remains on p or any alias of p, p stays guarded.
    • Once the last tracker across the alias group drops, every alias guarded solely via guard_aliases is opened back to PAGE_READWRITE and removed from g.protected, eliminating stale read-only guards.

Local Verification

  • cargo xtask policy — pass (191 files ok).
  • cargo clippy --locked -p victory-gpu --all-targets -- -D warnings (default and --all-features) — 0 warnings.
  • cargo test --locked -p victory-gpu --features diagnostics --lib watch::tests:: — 17/17 passed, including a_tracker_dropped_on_one_mapping_leaves_the_other_guarded and dropping_the_last_tracker_opens_both_mappings (L1455-1467).
  • Additional 3-view alias clique probe (a <-> b <-> c <-> a, matching xmem::map): verified dropping tracker ta while tb lives keeps all three views (a, b, c) guarded and faults/marks tb on a write through untracked view c, and dropping the final tracker tb opens all three views with zero lingering entries in g.protected.
  • Also verified a 4-way co-merge with #2295, #2294, and #2283 (which also touches watch.rs) on 63bcca43c6a0 merges with zero conflicts, passes strict clippy (--all-features), and passes all 6 targeted tests on both RTX 5090 and WARP.

Looks good to merge.

**@⁠fuzeofficlal** on GitHub · 2026-11-26 19:44 UTC · [original](https://github.com/Marvisak/VIctory/pull/2238#pullrequestreview-6079708532) · **approved these changes** Reviewed and verified `0c21a73bf5dcc09678ec1fabecd585811788f0f4` merged onto `origin/main` (`63bcca43c6a00a758510398fa43096ce7e4f7df0`) on Windows 11 x64 (RTX 5090 + Microsoft WARP, `--features diagnostics`, Rust 1.98.1 MSVC). ### Code Audit - In `Drop for Tracked` (`crates/victory-gpu/src/watch.rs:436-453`), once a page leaves `g.holders`, iterating `std::iter::once(page).chain(others)` and calling `open(&mut g, p)` only when `!watched(&g, p)` handles both invariants under the single `guards()` lock (no additional locks or lock-order changes): - While any tracker remains on `p` or any alias of `p`, `p` stays guarded. - Once the last tracker across the alias group drops, every alias guarded solely via `guard_aliases` is opened back to `PAGE_READWRITE` and removed from `g.protected`, eliminating stale read-only guards. ### Local Verification - `cargo xtask policy` — pass (`191 files ok`). - `cargo clippy --locked -p victory-gpu --all-targets -- -D warnings` (default and `--all-features`) — 0 warnings. - `cargo test --locked -p victory-gpu --features diagnostics --lib watch::tests::` — 17/17 passed, including `a_tracker_dropped_on_one_mapping_leaves_the_other_guarded` and `dropping_the_last_tracker_opens_both_mappings` (`L1455-1467`). - Additional 3-view alias clique probe (`a <-> b <-> c <-> a`, matching `xmem::map`): verified dropping tracker `ta` while `tb` lives keeps all three views (`a`, `b`, `c`) guarded and faults/marks `tb` on a write through untracked view `c`, and dropping the final tracker `tb` opens all three views with zero lingering entries in `g.protected`. - Also verified a 4-way co-merge with `#2295`, `#2294`, and `#2283` (which also touches `watch.rs`) on `63bcca43c6a0` merges with zero conflicts, passes strict clippy (`--all-features`), and passes all 6 targeted tests on both RTX 5090 and WARP. Looks good to merge.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
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/2238/head:github-bot/gh-2238'
git switch 'github-bot/gh-2238'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2238'
git switch 'github-bot/gh-2238'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2238'
git switch 'github-bot/gh-2238'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2238'
git switch 'main'
git merge --squash 'github-bot/gh-2238'
git switch 'main'
git merge --ff-only 'github-bot/gh-2238'
git switch 'main'
git merge 'github-bot/gh-2238'
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!2238
No description provided.