]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb.threads/multi-create: Double the existing stack size.
authorJohn Baldwin <jhb@FreeBSD.org>
Tue, 7 Mar 2023 00:55:22 +0000 (16:55 -0800)
committerJohn Baldwin <jhb@FreeBSD.org>
Tue, 7 Mar 2023 00:55:22 +0000 (16:55 -0800)
Setting the stack size to 2*PTHREAD_STACK_MIN actually lowered the
stack on FreeBSD rather than raising it causing non-main threads in
the test program to overflow their stack and crash.  Double the
existing stack size rather than assuming that the initial stack size
is PTHREAD_STACK_MIN.

gdb/testsuite/gdb.threads/multi-create.c

index f4a47c36e1dfb58b60d671fdde824c1ac5a3d469..9944ba5957a13836b7ad732e09c0a1f0d6fcc0eb 100644 (file)
@@ -39,11 +39,13 @@ create_function (void *arg)
   pthread_attr_t attr;
   pthread_t threads[NUM_THREAD];
   int args[NUM_THREAD];
+  size_t stacksize;
   int i = * (int *) arg;
   int j;
 
   pthread_attr_init (&attr); /* set breakpoint 1 here.  */
-  pthread_attr_setstacksize (&attr, 2*PTHREAD_STACK_MIN);
+  pthread_attr_getstacksize (&attr, &stacksize);
+  pthread_attr_setstacksize (&attr, 2 * stacksize);
 
   /* Create a ton of quick-executing threads, then wait for them to
      complete.  */
@@ -67,10 +69,12 @@ main (int argc, char **argv)
   pthread_attr_t attr;
   pthread_t threads[NUM_CREATE];
   int args[NUM_CREATE];
+  size_t stacksize;
   int n, i;
 
   pthread_attr_init (&attr);
-  pthread_attr_setstacksize (&attr, 2*PTHREAD_STACK_MIN);
+  pthread_attr_getstacksize (&attr, &stacksize);
+  pthread_attr_setstacksize (&attr, 2 * stacksize);
 
   for (n = 0; n < 100; ++n)
     {