diff options
| author | Aaron Jensen | 2018-02-27 09:15:40 -0800 |
|---|---|---|
| committer | Paul Eggert | 2018-02-27 09:28:30 -0800 |
| commit | e7a5b1bb671f0bc1c4dfbbbfc7b5ba1de1f39897 (patch) | |
| tree | 4104f9f4a2d274060ebd469ee7daac82e4f0d180 /src | |
| parent | b38cb1495d8916ce70785a33fb4dacf64edc904b (diff) | |
| download | emacs-e7a5b1bb671f0bc1c4dfbbbfc7b5ba1de1f39897.tar.gz emacs-e7a5b1bb671f0bc1c4dfbbbfc7b5ba1de1f39897.zip | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/systhread.c | 7 |
1 files changed, 7 insertions, 0 deletions
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, | |||
| 177 | if (pthread_attr_init (&attr)) | 177 | if (pthread_attr_init (&attr)) |
| 178 | return 0; | 178 | return 0; |
| 179 | 179 | ||
| 180 | /* Avoid crash on macOS with deeply nested GC (Bug#30364). */ | ||
| 181 | size_t stack_size; | ||
| 182 | size_t required_stack_size = sizeof (void *) * 1024 * 1024; | ||
| 183 | if (pthread_attr_getstacksize (&attr, &stack_size) == 0 | ||
| 184 | && stack_size < required_stack_size) | ||
| 185 | pthread_attr_setstacksize (&attr, required_stack_size); | ||
| 186 | |||
| 180 | if (!pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED)) | 187 | if (!pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED)) |
| 181 | { | 188 | { |
| 182 | result = pthread_create (thread_ptr, &attr, func, arg) == 0; | 189 | result = pthread_create (thread_ptr, &attr, func, arg) == 0; |