Skip to content

Commit a858def

Browse files
noobpwnftwsnicolet
authored andcommitted
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 #2303 No functional change
1 parent 7b06475 commit a858def

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/thread_win32_osx.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,14 @@ typedef std::condition_variable ConditionVariable;
7373
/// adjust it to TH_STACK_SIZE. The implementation calls pthread_create() with
7474
/// proper stack size parameter.
7575

76-
#if defined(__APPLE__)
76+
/// On toolchains where pthread is always available, ensure minimum stack size
77+
/// instead of relying on linker defaults which may be platform-specific.
78+
79+
#if defined(__APPLE__) || defined(__MINGW32__) || defined(__MINGW64__)
7780

7881
#include <pthread.h>
7982

80-
static const size_t TH_STACK_SIZE = 2 * 1024 * 1024;
83+
static const size_t TH_STACK_SIZE = 8 * 1024 * 1024;
8184

8285
template <class T, class P = std::pair<T*, void(T::*)()>>
8386
void* start_routine(void* ptr)

0 commit comments

Comments
 (0)