Blame SOURCES/autofs-5.1.7-use-default-stack-size-for-threads.patch

96dc52
autofs-5.1.7 - use default stack size for threads
96dc52
96dc52
From: Ian Kent <raven@themaw.net>
96dc52
96dc52
autofs uses PTHREAD_STACK_MIN to set the stack size for threads it
96dc52
creates.
96dc52
96dc52
In two cases it is used to reduce the stack size for long running
96dc52
service threads while it's used to allocate a larger stack for worker
96dc52
threads that can have larger memory requirements.
96dc52
96dc52
In recent glibc releases PTHREAD_STACK_MIN is no longer a constant
96dc52
which can lead to unexpectedly different stack sizes on different
96dc52
architectures and the autofs assumption it's a constant causes a
96dc52
compile failure.
96dc52
96dc52
The need to alter the stack size was due to observed stack overflow
96dc52
which was thought to be due the thread stack being too small for autofs
96dc52
and glibc alloca(3) usage.
96dc52
96dc52
Quite a bit of that alloca(3) usage has been eliminated from autofs now,
96dc52
particularly those that might be allocating largish amounts of storage,
96dc52
and there has been a lot of change in glibc too so using the thread
96dc52
default stack should be ok.
96dc52
96dc52
Signed-off-by: Ian Kent <raven@themaw.net>
96dc52
---
96dc52
 CHANGELOG          |    1 +
96dc52
 daemon/automount.c |   29 -----------------------------
96dc52
 daemon/state.c     |    6 +-----
96dc52
 lib/alarm.c        |    6 +-----
96dc52
 4 files changed, 3 insertions(+), 39 deletions(-)
96dc52
96dc52
--- autofs-5.1.7.orig/CHANGELOG
96dc52
+++ autofs-5.1.7/CHANGELOG
96dc52
@@ -79,6 +79,7 @@
96dc52
 - fix nonstrict offset mount fail handling.
96dc52
 - fix concat_options() error handling.
96dc52
 - eliminate some more alloca usage.
96dc52
+- use default stack size for threads.
96dc52
 
96dc52
 25/01/2021 autofs-5.1.7
96dc52
 - make bind mounts propagation slave by default.
96dc52
--- autofs-5.1.7.orig/daemon/automount.c
96dc52
+++ autofs-5.1.7/daemon/automount.c
96dc52
@@ -84,7 +84,6 @@ static size_t kpkt_len;
96dc52
 /* Attributes for creating detached and joinable threads */
96dc52
 pthread_attr_t th_attr;
96dc52
 pthread_attr_t th_attr_detached;
96dc52
-size_t detached_thread_stack_size = PTHREAD_STACK_MIN * 144;
96dc52
 
96dc52
 struct master_readmap_cond mrc = {
96dc52
 	PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER, 0, NULL, 0, 0, 0, 0};
96dc52
@@ -2614,34 +2613,6 @@ int main(int argc, char *argv[])
96dc52
 		if (start_pipefd[1] != -1) {
96dc52
 			res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat));
96dc52
 			close(start_pipefd[1]);
96dc52
-		}
96dc52
-		release_flag_file();
96dc52
-		macro_free_global_table();
96dc52
-		exit(1);
96dc52
-	}
96dc52
-
96dc52
-#ifdef _POSIX_THREAD_ATTR_STACKSIZE
96dc52
-	if (pthread_attr_setstacksize(
96dc52
-			&th_attr_detached, detached_thread_stack_size)) {
96dc52
-		logerr("%s: failed to set stack size thread attribute!",
96dc52
-		       program);
96dc52
-		if (start_pipefd[1] != -1) {
96dc52
-			res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat));
96dc52
-			close(start_pipefd[1]);
96dc52
-		}
96dc52
-		release_flag_file();
96dc52
-		macro_free_global_table();
96dc52
-		exit(1);
96dc52
-	}
96dc52
-#endif
96dc52
-
96dc52
-	if (pthread_attr_getstacksize(
96dc52
-			&th_attr_detached, &detached_thread_stack_size)) {
96dc52
-		logerr("%s: failed to get detached thread stack size!",
96dc52
-		       program);
96dc52
-		if (start_pipefd[1] != -1) {
96dc52
-			res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat));
96dc52
-			close(start_pipefd[1]);
96dc52
 		}
96dc52
 		release_flag_file();
96dc52
 		macro_free_global_table();
96dc52
--- autofs-5.1.7.orig/daemon/state.c
96dc52
+++ autofs-5.1.7/daemon/state.c
96dc52
@@ -1177,12 +1177,8 @@ int st_start_handler(void)
96dc52
 	status = pthread_attr_init(pattrs);
96dc52
 	if (status)
96dc52
 		pattrs = NULL;
96dc52
-	else {
96dc52
+	else
96dc52
 		pthread_attr_setdetachstate(pattrs, PTHREAD_CREATE_DETACHED);
96dc52
-#ifdef _POSIX_THREAD_ATTR_STACKSIZE
96dc52
-		pthread_attr_setstacksize(pattrs, PTHREAD_STACK_MIN*4);
96dc52
-#endif
96dc52
-	}
96dc52
 
96dc52
 	status = pthread_create(&thid, pattrs, st_queue_handler, NULL);
96dc52
 
96dc52
--- autofs-5.1.7.orig/lib/alarm.c
96dc52
+++ autofs-5.1.7/lib/alarm.c
96dc52
@@ -270,12 +270,8 @@ int alarm_start_handler(void)
96dc52
 	status = pthread_attr_init(pattrs);
96dc52
 	if (status)
96dc52
 		pattrs = NULL;
96dc52
-	else {
96dc52
+	else
96dc52
 		pthread_attr_setdetachstate(pattrs, PTHREAD_CREATE_DETACHED);
96dc52
-#ifdef _POSIX_THREAD_ATTR_STACKSIZE
96dc52
-		pthread_attr_setstacksize(pattrs, PTHREAD_STACK_MIN*4);
96dc52
-#endif
96dc52
-	}
96dc52
 
96dc52
 	status = pthread_condattr_init(&condattrs);
96dc52
 	if (status)