From: Aaron Jensen Date: Tue, 27 Feb 2018 17:15:40 +0000 (-0800) Subject: Require a larger stack size for threads (bug#30364) X-Git-Tag: emacs-27.0.90~5611 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=e7a5b1bb671f0bc1c4dfbbbfc7b5ba1de1f39897;p=emacs.git Require a larger stack size for threads (bug#30364) * src/systhread.c (sys_thread_create) [THREADS_ENABLED && HAVE_PTHREAD]: Require at least 8MB stack size for x64 and 4MB for x86. --- diff --git a/src/systhread.c b/src/systhread.c index 3f162a2bcbf..e972ed398ac 100644 --- a/src/systhread.c +++ b/src/systhread.c @@ -177,6 +177,13 @@ sys_thread_create (sys_thread_t *thread_ptr, const char *name, if (pthread_attr_init (&attr)) return 0; + /* Avoid crash on macOS with deeply nested GC (Bug#30364). */ + size_t stack_size; + size_t required_stack_size = sizeof (void *) * 1024 * 1024; + if (pthread_attr_getstacksize (&attr, &stack_size) == 0 + && stack_size < required_stack_size) + pthread_attr_setstacksize (&attr, required_stack_size); + if (!pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED)) { result = pthread_create (thread_ptr, &attr, func, arg) == 0;