xmem: VirtualFree(MEM_DECOMMIT) keeps physical-page views, zeroes pool backing #126
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/126"
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 LakshanSivakumar/Native-Victory-macOS. Originally posted by Olima34 on 2026-11-26T17:39:37Z.
Second of the two xmem PRs you asked for on #15 (the first is #124). Small and tested, like #108.
Bug.
VirtualFree(MEM_DECOMMIT)over a range that shows physical-page views called a plain decommit. That put fresh anonymous pages in place of the pool's at the title address, whilePhysical.viewsand the GPU's pool table still showed the pool there. After a recommit the title wrote the anonymous pages, and the GPU and any alias read the pool's old bytes. That is the same class of CPU/GPU split as #108.Fix (
xmem_physical::decommit):mprotecton macOS, so the views come back read-write.XMemVirtualAlloc's pool backing (Pool.backs, set inback_with_pool) andshownlists a single address for it.map_alias) is still read there;XMemAllocatePhysicalPagespages outlive their mappings, since the title may map them again.map_aliasshows at another address. Single-address alone would wipe numbered pages the title can map again.Tests.
xmem_posix::decommitting_pool_backed_memory_zeroes_the_pool: write, decommit and recommit pool-backed memory. The title address and the GPU's pool both read 0, and later writes reach the GPU's pool. Fails on main ("the GPU's pool reads zeros too").host_posix::decommitting_keeps_pages_shown_at_other_addresses: a physical page mapped at two addresses, andXMemVirtualAllocmemory with amap_alias. After decommitting one address, the other still reads the bytes. It guards against zeroing too much: it fails if either condition is dropped.Known limit (
shortcut:comment). Zeroing touches every page it zeroes, including pages never written.cargo test -p victory-hle --target x86_64-apple-darwin --lib(247), Windows clippy andcargo xtask policypass. It merges cleanly with #124. Not checked in game.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T18:09:58Z.
Merged, thanks. Views survive a decommit, and only lone pool backing is zeroed. Both x86_64 tests pass.