diff options
| author | Paul Eggert | 2018-02-28 16:27:06 -0800 |
|---|---|---|
| committer | Paul Eggert | 2018-02-28 16:31:20 -0800 |
| commit | ca8afa7672b830d6ed570c21599f3eadb0958d79 (patch) | |
| tree | a693b37a7588f129430e8902273a2c675c37d398 /src | |
| parent | fd5023874872dcb559cb7acdca6b019273c9de07 (diff) | |
| download | emacs-ca8afa7672b830d6ed570c21599f3eadb0958d79.tar.gz emacs-ca8afa7672b830d6ed570c21599f3eadb0958d79.zip | |
Require a larger stack size for threads on macOS (bug#30364)
* src/systhread.c (sys_thread_create)
[THREADS_ENABLED && HAVE_PTHREAD && DARWIN_OS]:
Require at least 8MB stack size for x64 and 4MB for x86 on macOS.
Do not merge to master.
Diffstat (limited to 'src')
| -rw-r--r-- | src/systhread.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/systhread.c b/src/systhread.c index 4ffb7db143a..c4dcc4e9069 100644 --- a/src/systhread.c +++ b/src/systhread.c | |||
| @@ -165,6 +165,15 @@ sys_thread_create (sys_thread_t *thread_ptr, const char *name, | |||
| 165 | if (pthread_attr_init (&attr)) | 165 | if (pthread_attr_init (&attr)) |
| 166 | return 0; | 166 | return 0; |
| 167 | 167 | ||
| 168 | #ifdef DARWIN_OS | ||
| 169 | /* Avoid crash on macOS with deeply nested GC (Bug#30364). */ | ||
| 170 | size_t stack_size; | ||
| 171 | size_t required_stack_size = sizeof (void *) * 1024 * 1024; | ||
| 172 | if (pthread_attr_getstacksize (&attr, &stack_size) == 0 | ||
| 173 | && stack_size < required_stack_size) | ||
| 174 | pthread_attr_setstacksize (&attr, required_stack_size); | ||
| 175 | #endif | ||
| 176 | |||
| 168 | if (!pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED)) | 177 | if (!pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED)) |
| 169 | { | 178 | { |
| 170 | result = pthread_create (thread_ptr, &attr, func, arg) == 0; | 179 | result = pthread_create (thread_ptr, &attr, func, arg) == 0; |