Skip to content

Commit

Permalink
Raise stack size to 8MB for pthreads
Browse files Browse the repository at this point in the history
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
  • Loading branch information
noobpwnftw authored and snicolet committed Sep 16, 2019
1 parent 7b06475 commit a858def
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/thread_win32_osx.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <pthread.h>

static const size_t TH_STACK_SIZE = 2 * 1024 * 1024;
static const size_t TH_STACK_SIZE = 8 * 1024 * 1024;

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

0 comments on commit a858def

Please sign in to comment.