diff --git a/thread_pthread.c b/thread_pthread.c index d9af238c884665..1e52d4f45b3116 100644 --- a/thread_pthread.c +++ b/thread_pthread.c @@ -777,8 +777,18 @@ size_t pthread_get_stacksize_np(pthread_t); # define MAINSTACKADDR_AVAILABLE 0 # endif #endif -#if MAINSTACKADDR_AVAILABLE && !defined(get_main_stack) -# define get_main_stack(addr, size) get_stack(addr, size) +#if MAINSTACKADDR_AVAILABLE +static int get_stack(void **, size_t *); +static int +get_main_stack(void **addr, size_t *size) +{ + get_stack(addr, size); + + /* On some architectures, the inital stack size may be too small, but fortunately, + it's growable. Bump it up to the minimum needed if it is too small. */ + if (*size < RUBY_VM_THREAD_VM_STACK_SIZE) + *size = RUBY_VM_THREAD_VM_STACK_SIZE; +} #endif #ifdef STACKADDR_AVAILABLE