[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:
@@ -171,7 +171,7 @@ bool DeallocFixed(void* base_address, size_t length,
|
||||
case DeallocationType::kDecommit:
|
||||
return Protect(base_address, length, PageAccess::kNoAccess);
|
||||
case DeallocationType::kRelease:
|
||||
assert_always("Error: Tried to release mapped memory!");
|
||||
return false;
|
||||
default:
|
||||
assert_unhandled_case(deallocation_type);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user