Watch: a page committed only in part stays changed instead of counting as unmapped #2234
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2236"
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 Marvisak/VIctory. Originally posted by denkencar-sketch on 2026-11-25T08:31:35Z.
Summary
protect()decides that a page "has nothing mapped" (and so counts it as taken without guarding it) by askingVirtualQueryabout the first 4 KiB of the 64 KiB page only. A page whose first part is reserved and the rest committed cannot be guarded (VirtualProtectfails across the reserved part), but the query seesMEM_RESERVE, so the page is taken without being guarded. It then leaves the tracker's changed set, and writes to its committed part are never seen.Change
The check walks the whole page with
VirtualQuery, region by region, and counts the page as unmapped only if no part of it is committed. A page committed in part stays changed, as the doc comment already says for a page that is mapped but cannot be guarded (it is copied whole at each take).Testing
watch::tests::a_page_committed_in_part_stays_changedreserves 64 KiB, commits all but the first 4 KiB, tracks it and takes it: onmainthe page is no longer changed after the take ("cannot be guarded, so still changed" fails); with this change it stays changed and a write to the committed part is copied at the next take.cargo clippy --workspace --all-targets [--all-features] --locked -- -D warningsis clean.Not tried: a run in the game.
modules::dstorage::tests::a_page_list_filled_after_its_request_startsfails now and then onmaintoo (5 of 20 runs ofcargo test -p victory-hle --lib); it is unrelated.AI-assisted.
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T08:48:32Z.
Review: COMMENTED
Watch: a page committed only in part stays changed —
unmappednow walks the whole page with VirtualQuery instead of checking only its start. Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1. Correct fix with a dedicated test; part of the watch.rs cluster #2236-#2239.Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T13:31:00Z.
Automated triage for the maintainers. This fixes the
unmappedcheck inwatch::protect.PAGEis 64 KiB, and onmainonly the region at the page's start is queried, so a page whose first 4 KiB is reserved but whose tail is committed counted as "nothing mapped" and was taken. Writes to its committed part were then missed. The new loop walks every region in the page withVirtualQueryand only reports unmapped when none is committed, withmax(at + 1)guarding against a zero-size region. The added testa_page_committed_in_part_stays_changedsets up exactly that layout. CI (check) passes.Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T14:56:54Z.
Review: APPROVED
Verified against
origin/main(940d32f) on Windows 11 + NVIDIA GeForce RTX 5090:cargo test -p victory-gpu watch::tests: 7/7 passed (includinga_page_committed_in_part_stays_changed).cargo clippy -p victory-gpu --all-targets -- -D warnings: 0 warnings.cargo xtask policy: 183 files ok.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T22:07:00Z.
Automated triage for the maintainers, second look (a review against current
main, with builds and tests where they could change the verdict).Closing because its test fails on current
mainand the layout does not occur. Since280b1505maindoes not track a page that holds committed private memory at all, sotrack(r, PAGE, true).expect("reserved memory is tracked")panics. The fix is right in substance, but it needs a page that is reserved when tracked and later committed in part with its first 4 KiB left reserved, which the title's allocations never produce. A version whose test commits the tail aftertrackwould be a fair edge-case fix.If this is mistaken, reply here with what was missed and it will be looked at again. Thank you for the contribution.
Pull request closed