]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
nptl: Correct stack size attribute when stack grows up [BZ #32574]
authorJohn David Anglin <danglin@gcc.gnu.org>
Wed, 29 Jan 2025 21:51:16 +0000 (16:51 -0500)
committerJohn David Anglin <danglin@gcc.gnu.org>
Sun, 2 Feb 2025 22:46:24 +0000 (17:46 -0500)
Set stack size attribute to the size of the mmap'd region only
when the size of the remaining stack space is less than the size
of the mmap'd region.

This was reversed.  As a result, the initial stack size was only
135168 bytes.  On architectures where the stack grows down, the
initial stack size is approximately 8384512 bytes with the default
rlimit settings.  The small main stack size on hppa broke
applications like ruby that check for stack overflows.

Signed-off-by: John David Anglin <dave.anglin@bell.net>
nptl/pthread_getattr_np.c

index e98e2df152c8fc40b5a7a757398a804f35225df9..43dd16d59cdde1d12785a7727b48991ac3e8090c 100644 (file)
@@ -145,9 +145,9 @@ __pthread_getattr_np (pthread_t thread_id, pthread_attr_t *attr)
                          > (size_t) iattr->stackaddr - last_to)
                        iattr->stacksize = (size_t) iattr->stackaddr - last_to;
 #else
-                     /* The limit might be too high.  */
+                     /* The limit might be too low.  */
                      if ((size_t) iattr->stacksize
-                         > to - (size_t) iattr->stackaddr)
+                         < to - (size_t) iattr->stackaddr)
                        iattr->stacksize = to - (size_t) iattr->stackaddr;
 #endif
                      /* We succeed and no need to look further.  */