xmem: VirtualFree(MEM_RELEASE) gives the pool backing back too #108
No reviewers
Labels
No labels
accessibility
bug
claimed
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
tester report
urgent
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/LakshanSivakumar--Native-Victory-macOS!108
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-108"
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?
@Olima34 on GitHub · 2026-11-26 16:25 UTC · original
Olima34:fix/xmem-virtualfree-releases-pool-backing→main· +55 −3 · 5 files · 1 commits · merged 2026-11-26 16:32 UTCWhat this changes
Refs #15 ("physical pages owned twice in xmem_posix"). One sure way two allocations end up sharing a title address on
main:XMemVirtualAlloc(…, MEM_RESERVE | MEM_COMMIT, …)backs the range with a pool of its own (back_with_pool), andtrackhands the region tohost_posix(adopt_region, x86_64).VirtualFree(p, 0, MEM_RELEASE), as the GDK allows.host_posix::VirtualFreeremoved the region and released the address space, but never calledxmem_physical::release_pool_backingand never dropped the reservation, althoughrelease_reservation's doc saidVirtualFree"does the same". The pool's views stayed inPhysical.views, and the GPU's pool table still mappedpto the freed pool.reserve_inis first fit, so the next allocation soon getspagain. From then on the CPU writes the new memory while the GPU,map_alias(CopyPageMappings) and the aliases read the old pool. A newback_with_poolatpalso records an overlapping view.Both releases now go through
xmem_posix::forget_physical(drop the reservation, thenrelease_pool_backing), whichVirtualFree(MEM_RELEASE)calls before giving the address space back. It also coversXMemMapPhysicalPagesviews placed in a plainVirtualAllocregion.How it was tested
virtual_free_gives_the_pool_backing_back_too(x86_64): afterVirtualFree(MEM_RELEASE)of pool-backedXMemVirtualAllocmemory, the address no longer shows that pool and the reservation is gone. It compares pool ids, so another test taking the address at once can't make it flaky. It fails onmain: "the old pool is still mapped at a freed address".virtual_alloc_meets_console_constraintsnow checks the same afterrelease_reservation.cargo test --target x86_64-apple-darwin -p victory-hle -p victory-loader -p victory(282, native probe included), arm64cargo test --workspace(690)cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings, also with--all-features; clippy for macOS reports nothing new in the files touchedcargo xtask policyChecklist
@LakshanSivakumar on GitHub · 2026-11-26 16:32 UTC · original · approved these changes
Checked the diff and merged it onto current main: virtual_free_gives_the_pool_backing_back_too and the rest of victory-hle pass on x86_64, native tests, windows clippy and xtask policy are clean, CI is green.