GPU: keep alias groups transitive and symmetrically guarded in title_memory_aliased #3161
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!3161
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3161"
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?
@fuzeofficlal on GitHub · 2026-11-26 10:35 UTC · original
fuzeofficlal:fix/gpu-watch-alias-guard-symmetry→main· +269 −12 · 1 files · 1 commits · openSummary
watch::title_memory_aliasedmaintains thealias_ofgraph and page-guard state when a physical page is mapped at multiple virtual addresses. Onmain, three gaps intitle_memory_aliasedcan leave alias groups partially linked or asymmetrically guarded, causing writes through another mapping of the same physical page to go silently unseen:title_memory_remapped->take->title_memory_aliasedrace:In
xmem::map,title_memory_remapped(base, len)releasesGUARDSbefore the per-page loop callstitle_memory_aliased(base + k * PAGE, shown). If a GPU submission runsTracked::takeonbase + k * PAGEin that window,pageentersg.protected(PAGE_READONLY) and its tracker becomes clean whileshownstaysPAGE_READWRITE.title_memory_aliasedonly checkedothers.iter().any(|&o| g.protected.contains(&(o / PAGE))), so it neither markedpagechanged nor guarded/opened the group—missing any write throughshownduring the window and leavingshownpermanentlyPAGE_READWRITEfor future writes. The same issue occurs whenothersitself mixes guarded and unguarded mappings.title_memory_aliasedonly linkedpagedirectly with each element ofothers. Whena <-> balready exists andtitle_memory_aliased(c, &[a])is called,bandcare never linked:take(b)leavescunguarded, writes (on_write/writing) andretakeatcmiss trackers holdingb, dropping a tracker oncopenscdespiteb's live tracker, and unmappingaviatitle_memory_remapped(a, PAGE)removesafrom both adjacency lists and seversbandccompletely.Passing an address in the same 64 KiB page as
atinothersinsertedpage -> pageintoalias_of.Changes
crates/victory-gpu/src/watch.rs:title_memory_aliased, return early for emptyothersor self-only inputs without creating self-links.page's existing component (new_group) and the merged connected component (clique) viaexpand_aliases, then link every distinct pair incliqueso alias groups remain complete cliques (preserved whentitle_memory_remappedremoves a page and its incident edges).new_groupis unguarded and every existing mapping in the clique is guarded, guard all pages innew_groupwithprotect(&mut g, &unguarded); if any page innew_group(including a busy sibling) cannot be guarded, callchanged(&mut g, page, page + 1, false)to mark all trackers and open every guard in the clique without saving post-write bytes.pagealready guarded while an existing mapping stayedPAGE_READWRITE, or mixed guard states inothers), callchanged(&mut g, page, page + 1, false)so neither raced writes nor subsequent writes through previously unguarded mappings go unseen.watch::testscovering the guarded-to-unguarded race and mixedothers, transitive alias propagation/retake/drop/bridge-unmap, guarding a newly joined group and busy-sibling rollback, and self-alias handling.Verification
main(63bcca43) before the fix and pass after the fix.cargo test -p victory-gpu --locked watch::tests: 19/19 passed.VICTORY_D3D12_DEBUG=1 cargo test -p victory-gpu --features diagnostics --locked(watch::tests,bindless::tests::heap_views_follow_writes_through_another_mapping,shadow::tests): all passed on hardware GPU and WARP.VICTORY_D3D12_WARP=1 cargo test -p victory-gpu --features diagnostics --locked: 250 passed, 0 failed, 1 ignored.cargo clippy --workspace --all-targets --locked -- -D warningsand--all-features: clean.cargo test -p xtask --locked policy::tests::repository_passes_policy: passed.@Dukestar69 on GitHub · 2026-11-26 10:48 UTC · original · approved these changes
Verified against
origin/main(63bcca4):cargo test -p victory-gpu --lib watch:: -- --test-threads=1: 19/19 passed (includingaliasing_a_guarded_page_to_an_unguarded_mapping_does_not_miss_writes,aliasing_a_newly_mapped_page_guards_its_group_and_handles_busy_siblings,aliasing_through_one_member_joins_the_whole_alias_group, andself_aliasing_adds_no_self_link_and_preserves_guards).cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Cleanly keeps alias groups transitive and symmetrically guarded in
title_memory_aliased.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
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.