From 3d671cba100e1e7f9f19ae43f33ebeba7fbd7a24 Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Wed, 21 Feb 2024 15:37:46 -0800 Subject: [PATCH] Allocator: Early return if past the end of the allocation range Fixes a bug where it would eventually hit the stack region and remap the range as RW even for ranges that don't overlap the stack. --- FEXCore/Source/Utils/Allocator.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/FEXCore/Source/Utils/Allocator.cpp b/FEXCore/Source/Utils/Allocator.cpp index b4a4d5538..d3b7066f6 100644 --- a/FEXCore/Source/Utils/Allocator.cpp +++ b/FEXCore/Source/Utils/Allocator.cpp @@ -297,6 +297,12 @@ namespace FEXCore::Allocator { if (c == ' ') { STEAL_LOG("[%d] ParseEnd; RegionBegin: %016lX RegionEnd: %016lX\n", __LINE__, RegionBegin, RegionEnd); + if (RegionEnd >= End) { + // Early return if we are completely beyond the allocation space. + close(MapsFD); + return Regions; + } + State = ScanEnd; // If the previous map's ending and the region we just parsed overlap the stack then we need to save the stack mapping.