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

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