Watch: dropping a tracker keeps a mapping guarded while a tracker holds its alias #2238
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2238
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2238"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@denkencar-sketch on GitHub · 2026-11-25 08:31 UTC · original
denkencar-sketch:fix/watch-alias-drop→main· +32 −3 · 1 files · 1 commits · openSummary
When a tracker is dropped,
Drop for Trackedopens (PAGE_READWRITE) every page that no tracker holds any more. That includes a page whichguard_aliasesguarded for a tracker of another mapping of the same memory. A write through the opened mapping then goes unseen, and the other tracker'stake()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_aliaseshad 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 onmain: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'stakemust see the page (onmainit returns nothing).dropping_the_last_tracker_opens_both_mappings: after the only tracker is dropped, neither page is left inprotected.The suite passed three times in a row.
cargo clippy --workspace --all-targets [--all-features] --locked -- -D warningsis clean.Not tried: a run in the game.
modules::dstorage::tests::a_page_list_filled_after_its_request_startsfails now and then onmaintoo (5 of 20 runs ofcargo test -p victory-hle --lib); it is unrelated.AI-assisted.
@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
6d86640aintomain940d32fin 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 (mainalone 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.
@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,
mainalready keeps a dropped page guarded while a tracker holds one of its aliases. What this adds, inDrop for Tracked(crates/victory-gpu/src/watch.rs), is the other half: when the last tracker on a page goes, its aliases (guarded byguard_aliaseswhen 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 testdropping_the_last_tracker_opens_both_mappingscovers it. CIcheckpasses and it merges cleanly.On your reply: confirmed. The part already in
mainis gone from the diff, and what remains is the alias opening and its test.Generated by Claude Code
@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.@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 (includinga_tracker_dropped_leaves_the_other_mapping_guardedanddropping_the_last_tracker_opens_both_mappings)cargo clippy -p victory-gpu --all-targets— 0 warningscargo 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).
@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 (
watchedcheck 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.@fuzeofficlal on GitHub · 2026-11-26 19:44 UTC · original · approved these changes
Reviewed and verified
0c21a73bf5dcc09678ec1fabecd585811788f0f4merged ontoorigin/main(63bcca43c6a00a758510398fa43096ce7e4f7df0) on Windows 11 x64 (RTX 5090 + Microsoft WARP,--features diagnostics, Rust 1.98.1 MSVC).Code Audit
Drop for Tracked(crates/victory-gpu/src/watch.rs:436-453), once a page leavesg.holders, iteratingstd::iter::once(page).chain(others)and callingopen(&mut g, p)only when!watched(&g, p)handles both invariants under the singleguards()lock (no additional locks or lock-order changes):por any alias ofp,pstays guarded.guard_aliasesis opened back toPAGE_READWRITEand removed fromg.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, includinga_tracker_dropped_on_one_mapping_leaves_the_other_guardedanddropping_the_last_tracker_opens_both_mappings(L1455-1467).a <-> b <-> c <-> a, matchingxmem::map): verified dropping trackertawhiletblives keeps all three views (a,b,c) guarded and faults/markstbon a write through untracked viewc, and dropping the final trackertbopens all three views with zero lingering entries ing.protected.#2295,#2294, and#2283(which also toucheswatch.rs) on63bcca43c6a0merges with zero conflicts, passes strict clippy (--all-features), and passes all 6 targeted tests on both RTX 5090 and WARP.Looks good to merge.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.