Blame SOURCES/autofs-5.1.2-increase-worker-thread-per-thread-stack-size.patch

4d476f
autofs-5.1.2 - increase worker thread per-thread stack size
4d476f
4d476f
From: Ian Kent <raven@themaw.net>
4d476f
4d476f
automount(8) uses a worker thread per-thread stack size of 1M which is
4d476f
sufficient for its needs.
4d476f
4d476f
But some glibc functions (such as nscd_getgr_r()) use alloca() to allocate
4d476f
working storage that can have an arbitary size. Since alloca() never fails
4d476f
there is no way to check for stack overflow. This has been fixed in more
4d476f
recent versions of glibc.
4d476f
4d476f
But for older version of glibc all that can be done by automount to avoid
4d476f
this is to increase the stack size.
4d476f
4d476f
Signed-off-by: Ian Kent <raven@themaw.net>
4d476f
---
4d476f
 CHANGELOG          |    1 +
4d476f
 daemon/automount.c |   14 +++++++++++++-
4d476f
 2 files changed, 14 insertions(+), 1 deletion(-)
4d476f
4d476f
--- autofs-5.0.7.orig/CHANGELOG
4d476f
+++ autofs-5.0.7/CHANGELOG
4d476f
@@ -247,6 +247,7 @@
4d476f
 - fix work around sss startup delay.
4d476f
 - improve scalability of direct mount path component.
4d476f
 - fix invalid reference in remount_active_mount().
4d476f
+- increase worker thread per-thread stack size.
4d476f
 
4d476f
 25/07/2012 autofs-5.0.7
4d476f
 =======================
4d476f
--- autofs-5.0.7.orig/daemon/automount.c
4d476f
+++ autofs-5.0.7/daemon/automount.c
4d476f
@@ -81,6 +81,7 @@ static int cloexec_works = 0;
4d476f
 /* Attributes for creating detached and joinable threads */
4d476f
 pthread_attr_t th_attr;
4d476f
 pthread_attr_t th_attr_detached;
4d476f
+size_t detached_thread_stack_size = PTHREAD_STACK_MIN * 144;
4d476f
 
4d476f
 struct master_readmap_cond mrc = {
4d476f
 	PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER, 0, NULL, 0, 0, 0, 0};
4d476f
@@ -2483,7 +2484,7 @@ int main(int argc, char *argv[])
4d476f
 
4d476f
 #ifdef _POSIX_THREAD_ATTR_STACKSIZE
4d476f
 	if (pthread_attr_setstacksize(
4d476f
-			&th_attr_detached, PTHREAD_STACK_MIN*64)) {
4d476f
+			&th_attr_detached, detached_thread_stack_size)) {
4d476f
 		logerr("%s: failed to set stack size thread attribute!",
4d476f
 		       program);
4d476f
 		res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat));
4d476f
@@ -2494,6 +2495,17 @@ int main(int argc, char *argv[])
4d476f
 	}
4d476f
 #endif
4d476f
 
4d476f
+	if (pthread_attr_getstacksize(
4d476f
+			&th_attr_detached, &detached_thread_stack_size)) {
4d476f
+		logerr("%s: failed to get detached thread stack size!",
4d476f
+		       program);
4d476f
+		res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat));
4d476f
+		close(start_pipefd[1]);
4d476f
+		release_flag_file();
4d476f
+		macro_free_global_table();
4d476f
+		exit(1);
4d476f
+	}
4d476f
+
4d476f
 	info(logging, "Starting automounter version %s, master map %s",
4d476f
 		version, master_list->name);
4d476f
 	info(logging, "using kernel protocol version %d.%02d",