diff options
author | Eric Wong <e@yhbt.net> | 2021-02-13 01:03:58 +0000 |
---|---|---|
committer | Eric Wong <e@yhbt.net> | 2021-02-13 02:15:32 +0000 |
commit | f441da11c290373e444771d4806dfe58d4d6d972 (patch) | |
tree | 068ca10e0ced313799a65d4e58d607387d5bddf0 | |
parent | fac3a390395520c10d6d0524448c9aa26768a7d1 (diff) | |
download | cmogstored-f441da11c290373e444771d4806dfe58d4d6d972.tar.gz |
As compilers and system C libraries change, the using a non-default stack size is too risky and can lead to difficult-to-diagnose problems. Using the default stack size seems to solve the segfaults at http_close reported by Xiao Yu <xyu@automattic.com>. Users on modern 64-bit systems were unlikely to find any benefit in using a small stack size with this code base. Users on 32-bit systems who wish to continue with a minimal stack should use "ulimit -s" in startup scripts or configure their process manager appropriately (e.g. setting the "LimitSTACK" directive in described in systemd.exec(5)). Reported-and-tested-by: Xiao Yu <xyu@automattic.com> Link: https://yhbt.net/cmogstored-public/CABfxMcW+kb5gwq3pSB_89P49EVv+4UkJXz+mUPQTy19AdrwbAg@mail.gmail.com/T/
-rw-r--r-- | thrpool.c | 21 |
1 files changed, 0 insertions, 21 deletions
@@ -12,24 +12,6 @@ struct mog_thr_start_arg { unsigned *do_quit; }; -/* - * we can lower this if we can test with lower values, NPTL minimum is 16K. - * We also use syslog() and *printf() functions which take a lot of - * stack under glibc, so we'll add BUFSIZ (8192 on glibc) to that - */ -#if MOG_LIBKQUEUE /* libkqueue uses quite a bit of stack */ -# define MOG_THR_STACK_SIZE (0) -#elif defined(__GLIBC__) || defined(__FreeBSD__) -# define MOG_THR_STACK_SIZE ((16 * 1024) + MAX(8192,BUFSIZ)) -# if defined(PTHREAD_STACK_MIN) && (PTHREAD_STACK_MIN > MOG_THR_STACK_SIZE) -# undef MOG_THR_STACK_SIZE -# define MOG_THR_STACK_SIZE PTHREAD_STACK_MIN -# endif -#else -# define MOG_THR_STACK_SIZE (0) -#endif -static const size_t stacksize = (size_t)MOG_THR_STACK_SIZE; - static sigset_t quitset; __attribute__((constructor)) static void thrpool_init(void) @@ -141,9 +123,6 @@ thrpool_add(struct mog_thrpool *tp, unsigned size, unsigned long *nr_eagain) CHECK(int, 0, pthread_attr_init(&attr)); - if (stacksize > 0) - CHECK(int, 0, pthread_attr_setstacksize(&attr, stacksize)); - thr = &tp->threads[tp->n_threads].thr; CHECK(int, 0, pthread_mutex_lock(&arg.mtx)); |