GPU: the guards make only views read-only, never committed private memory or free memory (the world froze with the structure builder on) #1147
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!1147
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1147"
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?
@tippythetaidum on GitHub · 2026-11-25 21:39 UTC · original
tippythetaidum:gpu/watch-free-memory→main· +185 −21 · 1 files · 2 commits · openProblem
With
VICTORY_BVH_BUILDER=1(the #994 stack merged into a tree based on0b0074e), the title froze 3, 18 and 4 seconds after the log's "the ray-tracing structure builder runs" line, in 3 runs of 3 on an RTX 5080. CPU time stopped advancing, the card sat at 7-10 % with no device loss and no driver event, and the process stayed alive. That is the same picture as #942 (all threads waiting, GPU idle).Thread dumps of the freezes, read with WinDbg against the builds' own PDBs:
watch::install::on_write, waiting for the guard lock inMutex::lock_contended: the submission thread, the title's main thread, a pipeline worker, and a D3D12 background thread inside the driver's shader compiler (nvgpucomp64, reached throughRtlDispatchException→RtlpCallVectoredHandlers).RtlAllocateHeap: the audio thread (apu::process) and the XInput poll.on_writeis a write fault at0x5a2e30. That is inside the process heap, whose handle (0x590000) is on the audio thread'sRtlAllocateHeapframe.So a page of the process heap had been made read-only by the guards. The heap's own code then faulted while holding the heap lock, the fault waited in
on_writefor the guard lock, and the guard lock's holder was waiting for the heap lock.Cause
Two ways in
watch.rslet committed memory that is not the title's be made read-only:is_viewanswers yes as soon as the first region isMEM_MAPPED.protect_herethen tries the whole range, and when that fails (it spans allocations) it protects it block by block, so every committed block in the range is made read-only, private memory included. In the third freeze's dump, which carries the memory map, the 4 MiB window0x400000-0x800000(beginning in a read-only mapped region at0x400000) had every committed private block in it read-only: the process heap's blocks0x590000-0x660000(allocation base0x570000, allocated read-write), plus0x430000-0x440000and0x6c0000-0x800000. That last one stops exactly at the window's end while the same allocation goes on read-write above it. The write faults there were at0x5e90dcand0x5b3920(audio freeing an Opus decoder, the XInput poll, a thread-poolmemset).is_viewalso took a range with free memory in it for a view ("a hole (a placeholder, or free)").uncommitted_endthen noted the blocks absent, to be guarded once mapped, so whatever the process allocated there later would have been guarded with it. Marvisak/VIctory#1849 found this under Wine (a null address's window over the process heap).Marvisak/VIctory's main has since moved to deciding region by region (280b150: anything but committed private memory and images). This change does the same here.
Change (
crates/victory-gpu/src/watch.rs)protect_herewalks the range region by region. It guards only memory that is not committed private memory and not an image: views, and placeholders, which are noted absent when their protection fails, as before.is_view: a free region ends the walk with "not a view".uncommitted_end: only placeholders (MEM_RESERVE) are uncommitted blocks to note absent, not free memory.committed_private_memory_beside_a_view_is_not_guarded: a view and committed private memory side by side in one split placeholder. The view is guarded and the private block stays writable. Without the change the private block ends up read-only.free_memory_is_not_tracked: a released reservation is not tracked. It is checked only while the memory is still free, since other tests allocate meanwhile.Tested
main9c184b3plus the two commits):cargo test -p victory-gpu --lib -- watch::gives 16 passed, 0 failed, 1 ignored (an event-log test).cargo clippy -p victory-gpu --all-targets -- -D warningsreports 7 errors, all in other files and already onmain(resource.rs,fpsbox.rs,draw.rs,pipeline/library.rs,queue.rs,shadow.rs,indirect.rs), none inwatch.rs.Possibly the same freeze as #942 (same base commit, same signature), not verified on that machine.
AI-assisted (Claude Code, Claude Opus 5.5): dump reading, the change and this text. Runs on my machine; no game data attached.
🤖 Generated with Claude Code
@tippythetaidum on GitHub · 2026-11-25 22:33 UTC · original
Related, and earlier: #804 (AscilCH) fixes one route to the same fault. A block noted
absentthat later becomes private memory is no longer treated as a known view (known_viewandguardcheckprotectedonly, andis_viewbefore a block leavesabsent).How they relate:
protect_herenever makes committed private memory read-only, whatever the guard state says.0x400000-0x800000began in mapped memory, sois_viewanswered yes at its first region, and the heap's blocks were protected block by block without ever beingabsent. #804 alone wouldn't stop that; the region check inprotect_heredoes.Both touch
watch.rs'sguard/known_viewneighbourhood, so whichever lands second needs a rebase. I'm happy to rebase this onto #804 if it goes first. The two tests check different things (absent_block_reallocated_as_private_memory_is_not_guardedthere,committed_private_memory_beside_a_view_is_not_guardedhere) and can both stay.AI-assisted (Claude Code, Claude Opus 5.5).
@Proudnoob4 on GitHub · 2026-11-25 23:17 UTC · original · edited 2026-11-25 23:26 UTC
AI-assisted (Claude Opus 5.5 in OpenCode), measured on my own machine. This replaces two overlapping AI-written reports I posted here earlier; on re-auditing the logs, some of their numbers were single samples or misattributed, and one said there were no visual artifacts, which was wrong.
Setup: RTX 4080 16 GB, Windows 10 22H2, Series X build, diagnostics release, prison-cell scene (~4,800 draws/frame). Three single 360 s runs, so this is a bundle comparison, not an isolated A/B:
Marvisak/VIctory#2825native f16#1168+#1147+#1164(VICTORY_CARD_PIECE_KB=16) +#1171+#1172+ a local commit (skip cleancard_dirtycopies; chunk wide compare dispatches to ≤ 65,535 groups)all other lists), 2nd-half mediancardmeter, 256-frame mean, steadycardmeterunchanged). Which of C's additions gave the 8 ms is not isolated.For this PR: ran in C with no crash. The last summary shows 396 guard faults and 291 page faults per frame, against 372 / 198 in B. I can't tell whether that rise comes from this PR or from the other changes in C.
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.