HLE: a view mapped during a physical write joins it #3488
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!3488
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3488"
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?
@kotekompotek on GitHub · 2026-11-27 08:34 UTC · original
kotekompotek:hle/late-physical-write-views→main· +157 −14 · 5 files · 1 commits · openA title view of a physical page mapped while a write into that page is still open now joins the write: xmem immediately opens a
kernel_will_writelease for the new view and holds it in the active write, so a tracker can no longer take/arm the view clean while streamed bytes are landing. Fixes #3481.This is the pre-drop interval the #2566 discussion left as separate follow-up. The failure exists independently on plain main, so this is based on main rather than stacked on #2566; the two are conceptually compatible but touch the same physical-write area — whichever lands second needs a normal rebase (mechanical merge-tree check shows a textual conflict in xmem.rs only).
What is in it
xmem.rs:Physicaltracks active writes by the same slice key asshown;ActiveWritekeeps the section alive, counts overlapping writers, and holdsKernelWriteleases for late-mapped views;PhysicalWriteis the RAII registration begun bywrite_physicaland — for a successfulpage_window— kept for the window's whole lifetime.mapopenskernel_will_writefor a view mapped over an active write;unmapdrops only the exact view's lease.page_window,XMemVirtualAlloc/XMemMapPhysicalPagesand the real victory-gpu write watch, plus the positive control (kernel_will_writeheld before tracking).test-hooksfeature on victory-gpu exposingwatch::track/Trackedfor integration tests — same shape as #2504's plumbing; production builds unaffected.Tested
63bcca43:late_window_view_must_be_dirty_before_window_dropFAILS with the issue's exact signature — "late title view is still clean after streamed bytes landed, before drop".victory-hlesuite 154 passed / 0 failed (baseline 152 + the 2 new). Fullvictory-gpusuite 226 passed / 5 failed / 1 ignored — the 5 failures are the documented environment-dependent baseline, bit-identical set on unmodified main.cargo clippy --locked -p victory-gpu -p victory-hle --all-targets -- -D warningsclean, including--all-features.cargo test --locked -p xtask: 6 passed — includes the repository policy test.Not tested
End-to-end interaction with the unmerged #2566/#2504 behavior in a running title (synthetic probes only, per the issue's own reproduction).
AI use: implementation and verification AI-assisted (Devin / SWE-2.1).
@oni-swr on GitHub · 2026-11-27 09:37 UTC · original
Independent Windows/WARP verification of #3488 at
8bd2ec785384edf8a21c268eefac47386bfd4dc5Environment: Windows 11 Pro build 10.0.26200, rustc 1.98.1, no physical GPU:
VICTORY_WARP=1andVICTORY_D3D12_WARP=1(WARP only),dxil.dll1.8.2502.11 from the Windows SDK 10.0.26100.0. Base ismain63bcca43c6; all three PR heads (#3487, #3488, #3489) sit directly on it.--locked, separate worktrees for base and head. Claim: #1633AI-assisted (Claude); I read the diff and the logs before posting. No game files were used. WARP is not hardware, so this says nothing about driver behaviour on AMD or NVIDIA.
Result: no regression found on WARP; the two new tests pass.
victory-gpu --lib: base 231 passed / 0 failed / 1 ignored; head 231 / 0 / 1 (3 runs each, identical).victory-hle(all targets): base 152 lib tests + 2 integration passed, 0 failed (3 runs). Head: 154 lib tests + 2 integration passed (the two new ones arelate_window_view_must_be_dirty_before_window_dropandlate_window_view_opened_before_take_stays_dirty) in 2 of 3 runs.modules::dstorage::tests::a_page_list_filled_after_its_request_startsfailed atdstorage.rs:1642(left: -2147024809=0x80070057,right: 0). I then ran that test alone 60 times and the wholevictory-hlelib 10 times, on base, on head, and on head merged with #3487: 0 failures anywhere. Other builds were running on this machine during the failed run, so I read it as a load-sensitive flake, but I cannot exclude a link to this PR, since the test exercises the page-list path it changes. Worth one more run on hardware.Diff read (no defect found; two things I did not audit):
PhysicalWrite::begintakes thephysical()lock, andmap()now callsvictory_gpu::kernel_will_writewhile holding it (lock order xmem, then watch). I did not check for the reverse order (a watch path calling back into xmem); if there is none, it is fine.track,take,clean,arm,savedandTrackedbecomepubinwatch.rsunconditionally, though they are re-exported only undertest-hooks(a dev-dependency ofvictory-hle). I did not run clippy, so I cannot say whether non-test builds warn.Overlap with #3487: both edit
victory-gpu/src/watch.rs. They merge with no conflict (git merge-tree), the hunks are disjoint (#3487 addsdirty_word; this PR only widens visibility), and I see no semantic interaction. Merged tree:victory-gpu235 passed / 0 failed,victory-hle154 passed / 0 failed, 3 runs each.@playcations on GitHub · 2026-11-27 12:28 UTC · original
The original two probes pass on
8bd2ec785384edf8a21c268eefac47386bfd4dc5. I found three narrower publication/lifetime gaps and reproduced each with deterministic CPU-only interleavings through the real mapper and write watch:title_memory_remapped, but before the new lease is acquired, it can take/arm the view. A private window write is then visible while the tracker is clean; the eventual saving lease records the streamed byte as the pre-image. My probe recordsclean=true, visible0x33, savedSome(0x33).write.views.removeends the lease before the host removes the mapping. Taking/arming and writing in the interval after the remap notification but beforeUnmapViewOfFile2again gives a clean tracker while the new byte is still visible.runshas resolved a valid section, butPhysicalWrite::beginlooks the IDs up again. Freeing an ID in between skips registration even though an existing view keeps the section alive andmap_aliascan still make a late view from it. That view takes clean during the window.I prepared a follow-up branch on your exact head, ending at
652f090eb41e6967c746d78fc52225854426f7bf(complete diff):All three new race probes fail on your head and pass on the follow-up. The follow-up also covers overlapping windows, split views and address reuse, and preserves the original two tests. All 19 xmem tests pass under Wine. In the broader HLE suite the original head has 148 passes / 6 failures and the follow-up 153 / 6, with exactly the same failure set in this environment.
For the landing-order question, I also resolved the textual conflict with unchanged #2566 at
89a4b63on a separate integration branch, mergef60fbd6acf4d79f06de8f9bc8c53a3fd2cf14051. All 21 xmem tests pass there. A new control checks that bothwrite_physicalandPageWindowretain the original byte for a view armed before the write; it fails without #2566 and passes in the combined tree. This is an offered merge resolution, not a competing PR.Both trees pass Windows-target Clippy for
victory-gpu/victory-hlewith--all-targets, default and--all-features,-D warnings, and the asset policy. Environment: Ubuntu26.04.1, Wine11.22 Staging, Rust1.98.1/cargo-xwin; no GPU or game files exposed. Test-only hooks inject the legal interleavings without timing sleeps. Sol source review and a separate Astra concurrency audit informed the follow-up; I inspected the code and executed logs before posting. AI-assisted with Codex GPT-6.1 Sol.Two inherited areas remain outside these executed success-path probes: an end-of-write address snapshot can be replaced before its notification, and host unmap/rollback errors are ignored. The source audit identified those paths; I did not observe a naturally failing valid host unmap. They deserve separate coverage before claiming all mapping failure/address-reuse races are closed.
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.