From 361271826e27fd15aa724b1806c5f58003760977 Mon Sep 17 00:00:00 2001 From: Borchev <4501931+Borchev@users.noreply.github.com> Date: Tue, 30 Jul 2024 12:40:42 -0700 Subject: [PATCH] Fix SearchFree function bug (#339) --- src/core/memory.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/core/memory.cpp b/src/core/memory.cpp index 27e05f41..aa552d51 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp @@ -348,7 +348,15 @@ void MemoryManager::NameVirtualRange(VAddr virtual_addr, size_t size, std::strin it->second.name = name; } VAddr MemoryManager::SearchFree(VAddr virtual_addr, size_t size, u32 alignment) { + // If the requested address is below the mapped range, start search from the lowest address + auto min_search_address = impl.SystemManagedVirtualBase(); + if (virtual_addr < min_search_address) { + virtual_addr = min_search_address; + } + auto it = FindVMA(virtual_addr); + ASSERT_MSG(it != vma_map.end(), "Specified mapping address was not found!"); + // If the VMA is free and contains the requested mapping we are done. if (it->second.IsFree() && it->second.Contains(virtual_addr, size)) { return virtual_addr;