Author: bonefish Date: 2010-01-05 23:02:58 +0100 (Tue, 05 Jan 2010) New Revision: 34912 Changeset: http://dev.haiku-os.org/changeset/34912/haiku Modified: haiku/trunk/src/system/kernel/vm/vm.cpp Log: unmap_and_free_physical_pages(): Added missing check whether the page mapping is actually present. This would have resulted in page 0 being freed over and over again, if we hadn't also incorrectly tried to look up the page by the virtual instead of the physical address. So we were actually freeing random pages. Fortunately the virtual addresses are kernel addresses, so that the affected pages lay beyond 2 GB and probably weren't used at this point yet. Modified: haiku/trunk/src/system/kernel/vm/vm.cpp =================================================================== --- haiku/trunk/src/system/kernel/vm/vm.cpp 2010-01-05 19:19:11 UTC (rev 34911) +++ haiku/trunk/src/system/kernel/vm/vm.cpp 2010-01-05 22:02:58 UTC (rev 34912) @@ -2880,8 +2880,9 @@ addr_t physicalAddress; uint32 flags; - if (map->ops->query(map, current, &physicalAddress, &flags) == B_OK) { - vm_page* page = vm_lookup_page(current / B_PAGE_SIZE); + if (map->ops->query(map, current, &physicalAddress, &flags) == B_OK + && (flags & PAGE_PRESENT) != 0) { + vm_page* page = vm_lookup_page(physicalAddress / B_PAGE_SIZE); if (page != NULL) vm_page_set_state(page, PAGE_STATE_FREE); }