From 331655182d982f01a804da6d5c1bcaef78d334c7 Mon Sep 17 00:00:00 2001 From: LC Date: Tue, 21 Jul 2026 15:12:37 -0400 Subject: [PATCH] ThreadManager: Fix error return values in FrontendAllocateSlots() If ftruncate or the mmap ever fail for whatever reason, then we need to return the current size, rather than the new size. --- .../LinuxSyscalls/ThreadManager.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/ThreadManager.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/ThreadManager.cpp index 3e50b2f85..b9906f025 100644 --- a/Source/Tools/LinuxEmulation/LinuxSyscalls/ThreadManager.cpp +++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/ThreadManager.cpp @@ -86,19 +86,17 @@ uint32_t ThreadManager::StatAlloc::FrontendAllocateSlots(uint32_t NewSize) { if (ftruncate(fd, NewSize) == -1) { LogMan::Msg::EFmt("[StatAlloc] ftruncate more failed"); - - goto err; + close(fd); + return CurrentSize; } - { - auto SharedBase = FEXCore::Allocator::mmap(Base, NewSize, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_FIXED, fd, 0); - if (SharedBase == MAP_FAILED) { - LogMan::Msg::EFmt("[StatAlloc] allocate more mmap shm failed"); - goto err; - } + auto SharedBase = FEXCore::Allocator::mmap(Base, NewSize, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_FIXED, fd, 0); + if (SharedBase == MAP_FAILED) { + LogMan::Msg::EFmt("[StatAlloc] allocate more mmap shm failed"); + close(fd); + return CurrentSize; } -err: close(fd); return NewSize; }