autofs-5.1.2 - increase worker thread per-thread stack size From: Ian Kent automount(8) uses a worker thread per-thread stack size of 1M which is sufficient for its needs. But some glibc functions (such as nscd_getgr_r()) use alloca() to allocate working storage that can have an arbitary size. Since alloca() never fails there is no way to check for stack overflow. This has been fixed in more recent versions of glibc. But for older version of glibc all that can be done by automount to avoid this is to increase the stack size. Signed-off-by: Ian Kent --- CHANGELOG | 1 + daemon/automount.c | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 46487f1..a2a22ce 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -60,6 +60,7 @@ xx/xx/2016 autofs-5.1.3 - fix invalid reference in remount_active_mount(). - use malloc for expanded map location. - fix offset mount location multiple expansion. +- increase worker thread per-thread stack size. 15/06/2016 autofs-5.1.2 ======================= diff --git a/daemon/automount.c b/daemon/automount.c index d27804d..fcef40b 100644 --- a/daemon/automount.c +++ b/daemon/automount.c @@ -81,6 +81,7 @@ static int cloexec_works = 0; /* Attributes for creating detached and joinable threads */ pthread_attr_t th_attr; pthread_attr_t th_attr_detached; +size_t detached_thread_stack_size = PTHREAD_STACK_MIN * 144; struct master_readmap_cond mrc = { PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER, 0, NULL, 0, 0, 0, 0}; @@ -2476,7 +2477,7 @@ int main(int argc, char *argv[]) #ifdef _POSIX_THREAD_ATTR_STACKSIZE if (pthread_attr_setstacksize( - &th_attr_detached, PTHREAD_STACK_MIN*64)) { + &th_attr_detached, detached_thread_stack_size)) { logerr("%s: failed to set stack size thread attribute!", program); res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat)); @@ -2487,6 +2488,17 @@ int main(int argc, char *argv[]) } #endif + if (pthread_attr_getstacksize( + &th_attr_detached, &detached_thread_stack_size)) { + logerr("%s: failed to get detached thread stack size!", + program); + res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat)); + close(start_pipefd[1]); + release_flag_file(); + macro_free_global_table(); + exit(1); + } + info(logging, "Starting automounter version %s, master map %s", version, master_list->name); info(logging, "using kernel protocol version %d.%02d",