watch: clear stale JOURNAL.written entries on title_memory_remapped (#102) #112
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/Belobug--VIctory-Belobug-AMD!112
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-112"
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?
@adritoyalser on GitHub · 2026-11-25 14:24 UTC · original
adritoyalser:fix/watch-journal-remap-cleanup→main· +58 −0 · 2 files · 2 commits · openSummary
Fixes #102.
Root Cause
watch::title_memory_remapped(at, len)cleared guarded-block state (protected,clean,holes,aliased), bumpedREGION_EPOCHS, and invalidated shadows/placed textures/bindless views, but never removed pages in[at, at + len)from the process-globalJOURNAL.writtenmap.When
texture::tests::warp_write_watched_texture_uploads_only_when_writtenran beforewatch::tests::written_pages_are_reported_to_every_askerin a serial run:warp_write_watched_texture_uploads_only_when_writtenallocated aMEM_WRITE_WATCHbuffer viaVirtualAlloc, wrote to it, recorded(raw / PAGE, stamp)inJOURNAL.writtenviawatch::writes, and calledVirtualFreewithout clearingJOURNAL.written.written_pages_are_reported_to_every_askerallocated a freshMEM_WRITE_WATCHbuffer viaVirtualAlloc, Windows reused the just-freed 64 KiB-aligned virtual address, andwatch::writes(start, end, false)returned the staleJOURNAL.writtenentry from the freed allocation — failingassert!(before.is_empty())atwatch.rs:998.The exact failure reproduces 100% deterministically on
01aadd1with:Changes
crates/victory-gpu/src/watch.rs:title_memory_remapped(at, len), remove whole contained pages (at.div_ceil(PAGE)..end / PAGE) fromJOURNAL.written(safe forwrites_guardedbecauseg.protected/g.cleanare also cleared for the same range, and avoids clobbering any neighboring allocation on a partial 64 KiB page).title_memory_remapped(p, 4 * PAGE)beforeVirtualFreeinwritten_pages_are_reported_to_every_asker.watch::tests::remapped_memory_clears_stale_write_journal.crates/victory-gpu/src/texture.rs:crate::watch::title_memory_remapped(raw as usize, alloc_size)beforeVirtualFreeinwarp_write_watched_texture_uploads_only_when_written(consistent with the otherwatch::teststhat notifytitle_memory_remappedon teardown).Verification
cargo test -q -p victory-gpu --lib --locked -- --test-threads=1 warp_write_watched_texture written_pages_are_reported-> 1 passed, 1 failed (watch.rs:998: assertion failed: before.is_empty()).cargo test -q -p victory-gpu --lib --locked -- --test-threads=1 warp_write_watched_texture written_pages_are_reported remapped_memory_clears_stale_write_journal-> 3 passed, 0 failed.cargo test -q -p victory-gpu --lib --locked -- --test-threads=1 texture:: watch::-> 12 passed, 0 failed.cargo clippy -q -p victory-gpu --lib --tests --locked --no-deps-> 0 warnings inwatch.rsandtexture.rs.@adritoyalser on GitHub · 2026-11-25 15:27 UTC · original
Good suggestion @gut0to! Expanded
remapped_memory_clears_stale_write_journalto allocate 3 pages and calltitle_memory_remapped(p + 1, 2 * PAGE), verifying that only the fully covered middle page is cleared while both partially covered adjacent pages (baseandbase + 2) preserve their write-journal stamps.texture::+watch::tests pass (12 passed, 0 failed).@Adika713 on GitHub · 2026-11-25 16:04 UTC · original
Verified on AMD Radeon RX 6950 XT, Ryzen 5 3600, 32 GB RAM, Windows 11,
Rust 1.98.1 / Cargo 1.98.1. No game data; the title was not run.
Each tree used an isolated
CARGO_TARGET_DIR.Before, at
upstream/main01aadd193d57e71fb4d57810eb2fdd1bc95c950b, fromF:\VIctory-Belobug-AMDwithCARGO_TARGET_DIR=F:\VIctory-Belobug-AMD\_agent_tmp\target-gpu-main-verify:20 runs: 18 failed, 2 passed. Every failure was
watch::tests::written_pages_are_reported_to_every_askerpanicking atwatch.rs:998:9withassertion failed: before.is_empty(). A separate sampleof 20 serial full-lib runs at main failed 15 times on the same test.
After, at PR head
a1e531b, from a detached worktree atF:\VIctory-Belobug-AMD\_agent_tmp\watch-112withCARGO_TARGET_DIR=F:\VIctory-Belobug-AMD\_agent_tmp\target-watch-112:test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 114 filtered out.test result: ok. 112 passed; 0 failed; 4 ignored; 0 measured; 0 filtered out.test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 115 filtered out.Overlap: PR #115 head
c866e7aalso makes the flake disappear (20/20deterministic and 20/20 full serial runs passed), but it only changes the test.
PR #127 head
c9e45b4toucheswatch.rsandtexture.rsbut does not compilehere:
error[E0425]: cannot find type 'F' in this scopeathost.rs:3134andhost.rs:3138; no tests ran. I wrote no competing fix.Not tested: the game, or the full workspace suite.
AI-assisted: OpenCode, model Big Pickle. No game data.
@ -718,2 +718,4 @@}}{let first = at.div_ceil(PAGE);@gut0to on GitHub · 2026-11-25 14:53 UTC · original
Could the regression test also cover a partial-page remap boundary, verifying that fully covered pages are cleared while the adjacent partially covered page is preserved? The ceil(at / PAGE)..end / PAGE bounds prevent deleting neighboring-page state, and the current test uses only a page-aligned range. AI-assisted review.
@gut0to on GitHub · 2026-11-25 14:53 UTC · original · reviewed
AI-assisted review: I checked the range bounds and the current regression-test coverage.
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.