public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] gdb.threads/multi-create: Double the existing stack size.
@ 2023-03-07  0:58 John Baldwin
  0 siblings, 0 replies; only message in thread
From: John Baldwin @ 2023-03-07  0:58 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=3c75f00adcea9d57c0d92669249dd884e49c4c3b

commit 3c75f00adcea9d57c0d92669249dd884e49c4c3b
Author: John Baldwin <jhb@FreeBSD.org>
Date:   Mon Mar 6 16:55:22 2023 -0800

    gdb.threads/multi-create: Double the existing stack size.
    
    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.

Diff:
---
 gdb/testsuite/gdb.threads/multi-create.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/gdb/testsuite/gdb.threads/multi-create.c b/gdb/testsuite/gdb.threads/multi-create.c
index f4a47c36e1d..9944ba5957a 100644
--- a/gdb/testsuite/gdb.threads/multi-create.c
+++ b/gdb/testsuite/gdb.threads/multi-create.c
@@ -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)
     {

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-03-07  0:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-07  0:58 [binutils-gdb] gdb.threads/multi-create: Double the existing stack size John Baldwin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).