From d1f6440a7682591c29ef2f7b85f5c1e79ac23c17 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Thu, 26 Mar 2026 10:55:11 +0100 Subject: [PATCH] Fix stack overflow on mac when cooking game with too small stack size --- Source/Editor/Cooker/GameCooker.cpp | 3 ++- Source/Engine/Threading/ThreadSpawner.h | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Source/Editor/Cooker/GameCooker.cpp b/Source/Editor/Cooker/GameCooker.cpp index c7acfa2d8..98cf609a7 100644 --- a/Source/Editor/Cooker/GameCooker.cpp +++ b/Source/Editor/Cooker/GameCooker.cpp @@ -535,7 +535,8 @@ bool GameCooker::Build(BuildPlatform platform, BuildConfiguration configuration, { Function f; f.Bind(ThreadFunction); - const auto thread = ThreadSpawner::Start(f, GameCookerServiceInstance.Name, ThreadPriority::Highest); + uint32 stackSize = 4 * 1024 * 1024; // Larger stack + const auto thread = ThreadSpawner::Start(f, GameCookerServiceInstance.Name, ThreadPriority::Highest, stackSize); if (thread == nullptr) { GameCookerImpl::IsRunning = false; diff --git a/Source/Engine/Threading/ThreadSpawner.h b/Source/Engine/Threading/ThreadSpawner.h index f6300f1de..18c52f784 100644 --- a/Source/Engine/Threading/ThreadSpawner.h +++ b/Source/Engine/Threading/ThreadSpawner.h @@ -19,11 +19,12 @@ public: /// The callback function. /// Name of the thread. /// The thread priority. + /// The size of the stack to create. 0 means use the current thread's stack size /// The created thread. - static Thread* Start(const Function& callback, const String& threadName, ThreadPriority priority = ThreadPriority::Normal) + static Thread* Start(const Function& callback, const String& threadName, ThreadPriority priority = ThreadPriority::Normal, uint32 stackSize = 0) { auto runnable = New(true); runnable->OnWork = callback; - return Thread::Create(runnable, threadName, priority); + return Thread::Create(runnable, threadName, priority, stackSize); } };