From a858defd332bddd828c9280a9e326a0b750b3dda Mon Sep 17 00:00:00 2001 From: noobpwnftw Date: Sun, 15 Sep 2019 00:18:10 +0800 Subject: [PATCH] Raise stack size to 8MB for pthreads It seems there is no other way to specify stack size on std::thread than linker flags and the effective flags are named differently in many toolchains. On toolchains where pthread is always available, this patch changes the stack size change in our C++ code via pthread to ensure a minimum stack size of 8MB, instead of relying on linker defaults which may be platform-specific. Also raises default stack size on OSX to current Linux default (8MB) just to be safe. Closes https://github.com/official-stockfish/Stockfish/pull/2303 No functional change --- src/thread_win32_osx.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/thread_win32_osx.h b/src/thread_win32_osx.h index 88900540..5583a06e 100644 --- a/src/thread_win32_osx.h +++ b/src/thread_win32_osx.h @@ -73,11 +73,14 @@ typedef std::condition_variable ConditionVariable; /// adjust it to TH_STACK_SIZE. The implementation calls pthread_create() with /// proper stack size parameter. -#if defined(__APPLE__) +/// On toolchains where pthread is always available, ensure minimum stack size +/// instead of relying on linker defaults which may be platform-specific. + +#if defined(__APPLE__) || defined(__MINGW32__) || defined(__MINGW64__) #include -static const size_t TH_STACK_SIZE = 2 * 1024 * 1024; +static const size_t TH_STACK_SIZE = 8 * 1024 * 1024; template > void* start_routine(void* ptr) -- 2.39.2