[Posix] Fix DeallocFixed crashes / memory leaks

BaseHeap::Dispose() walks the page table and calls
DeallocFixed(addr, 0, kRelease) for every allocated page region.
These addresses are within file-backed view mappings (i.e. guest memory).
On Windows, VirtualFree on file-mapped pages silently returns FALSE.
On POSIX, the code hit assert_always() and crashed. Changed to return false
to match Windows behavior.

Memory leaks from munmap(addr, 0):

Callers passed length=0 to DeallocFixed(kRelease). On Windows this works because
VirtualFree(addr, 0, MEM_RELEASE) means "release the entire region" — Windows
ignores the length parameter for MEM_RELEASE and always frees the whole
allocation. On POSIX, munmap(addr, 0) fails with EINVAL, so the memory was
silently leaked every time.
This commit is contained in:
Herman S.
2026-02-15 14:37:28 +09:00
parent b7add3e0ec
commit bf6e1a81eb
4 changed files with 8 additions and 6 deletions

View File

@@ -38,7 +38,7 @@ X64CodeCache::X64CodeCache() = default;
X64CodeCache::~X64CodeCache() {
if (indirection_table_base_) {
xe::memory::DeallocFixed(indirection_table_base_, 0,
xe::memory::DeallocFixed(indirection_table_base_, kIndirectionTableSize,
xe::memory::DeallocationType::kRelease);
}