Views guarded while they are mapped stay writable #102
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/102"
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?
Imported from DexNom/VIctory. Originally posted by Castyan on 2026-11-26T20:05:15Z.
On
main, independent of #61 and #64. Split out of #64.What
935bf44Views guarded while they are mapped stay writable. Ported from avatarmanz/VIctory-7900XTX@160d222 (itswatchpart, adapted to ouraliasedblocks andcleansets). A refresh on another thread could guard a view's new blocks between the mapping and its notification. The notification then forgot them while leaving them read-only, so the title's next write was an access violation nobody caught. A test reproduced it as aSTATUS_ACCESS_VIOLATIONbefore the fix. Thewatchtests now forget their guards before freeing their memory.1240d8bframe's next-tick wait is checked by its time-out, not the wall clock.Before:
watch::tests::a_view_mapped_beside_a_guarded_one_makes_it_check_againfailed about 1 run in 100 under load. After: 0 failures in 100 pairs of thevictory-gputest binary run two at a time, plus 100 ordinary runs (measured on the #64 tree).Checks (RTX 5060, at
1240d8bonmain)cargo clippy --workspace --all-targets --locked -- -D warnings, with and without--all-features: clean.cargo test --workspace --locked: 684 passed, 0 failed, 12 ignored.🤖 Generated with Claude Code
Imported from DexNom/VIctory. Originally posted by murillojndem on 2026-11-30T22:55:08Z.
A crash on an RX 7900 XT matches the state this PR prevents. Build: main
4ad86927with--features diagnostics,--profile diag. A DirectStorage worker stopped on an access violation nobody handled:With the build's PDB the stack is
zlib_rs::inflate::inflate_fast_help_avx2<zlib_rs::inflate::inflate<dstorage::inflate<dstorage::execute(dstorage.rs:901) <into_destination<fill_virtual_destination<dstorage::work. The write began a 64 KiB block (0x129330000) that was read-only and not inGuards::protected, soon_writepassed it on;kernel_will_writebefore the inflate only opens blocks the guards know. Nothing in the log says whether a mapping changed at that address at that moment, so this matches the end state; it does not prove the interleaving.I also checked the interleaving on main with a placeholder-backed section view, the way
xmem.rsmapmakes them:guard()afterMapViewOfFile3and beforetitle_memory_remappedleaves the view read-only and forgotten (the next write is that unhandled fault); with the guarded blocks given write access back intitle_memory_remapped, as here, it is writable, and the nextguard()reports the block and guards it again. The refreshes that reachguard()(Shadow::update_free,merge_under_writes, the texture guard check) take notitle_memory_readingpin, so theRemappingheld byXMemMapPhysicalPagesdoes not keep them out.For what it is worth, one gap is the same before and after this PR: when
unmapcuts a view and part of it stays mapped, that part is a placeholder betweenUnmapViewOfFile2and themapthat puts it back, and a write to it then (a DirectStorage worker takes no pin) faults with nothing to open.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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.