From fd6cea4698e750dbde7d1618533361e52b00f916 Mon Sep 17 00:00:00 2001 From: Tony Wasserka Date: Sat, 21 Mar 2026 21:22:01 +0100 Subject: [PATCH] CodeCache: Fix glibc debug mode assertion If begin == end, the first vector::erase() call would invalidate the begin iterator. --- FEXCore/Source/Interface/Core/CodeCache.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/FEXCore/Source/Interface/Core/CodeCache.cpp b/FEXCore/Source/Interface/Core/CodeCache.cpp index 648a5bd3a..91b4059d5 100644 --- a/FEXCore/Source/Interface/Core/CodeCache.cpp +++ b/FEXCore/Source/Interface/Core/CodeCache.cpp @@ -399,13 +399,13 @@ bool CodeCache::LoadData(Core::InternalThreadState* Thread, std::byte* MappedCac auto begin = ranges::lower_bound(BlockList, BinarySection.BeginVA - BinarySection.FileStartVA, std::less {}, &BlockListEntry::first); auto end = ranges::upper_bound(begin, BlockList.end(), BinarySection.EndVA - BinarySection.FileStartVA - 1, std::less {}, &BlockListEntry::first); - BlockList.erase(end, BlockList.end()); - BlockList.erase(BlockList.begin(), begin); - if (BlockList.empty()) { + if (begin == end) { // Not an error since there is just no data to load LogMan::Msg::IFmt("No blocks cached in this range, aborting"); return true; } + BlockList.erase(end, BlockList.end()); + BlockList.erase(BlockList.begin(), begin); } // Read relocations