public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: John Baldwin <jhb@FreeBSD.org>
To: gdb-patches@sourceware.org
Subject: [PATCH 1/5] gdb.threads/multi-create: Double the existing stack size.
Date: Fri, 17 Feb 2023 12:38:14 -0800	[thread overview]
Message-ID: <20230217203818.11287-2-jhb@FreeBSD.org> (raw)
In-Reply-To: <20230217203818.11287-1-jhb@FreeBSD.org>

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 | 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)
     {
-- 
2.38.1


  reply	other threads:[~2023-02-17 20:38 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-17 20:38 [PATCH 0/5] Various test suite fixes (mostly thread related) John Baldwin
2023-02-17 20:38 ` John Baldwin [this message]
2023-02-17 20:38 ` [PATCH 2/5] gdb.base/catch-syscall.exp: Remove some Linux-only assumptions John Baldwin
2023-02-17 20:38 ` [PATCH 3/5] gdb.threads/execl.c: Ensure all threads are started before execl John Baldwin
2023-02-17 20:38 ` [PATCH 4/5] gdb.threads/next-bp-other-thread.c: Ensure child thread is started John Baldwin
2023-02-17 20:38 ` [PATCH 5/5] gdb tests: Allow for "LWP" in thread IDs from info threads John Baldwin
2023-03-03 17:59 ` [PING] [PATCH 0/5] Various test suite fixes (mostly thread related) John Baldwin
2023-03-03 19:16 ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230217203818.11287-2-jhb@FreeBSD.org \
    --to=jhb@freebsd.org \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).