From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1936) id B2D913858C66; Tue, 7 Mar 2023 00:58:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B2D913858C66 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1678150714; bh=fhWW7OmiDJNV1MF34OvCp9QbkzEQCNoMpqXTDDRGN4E=; h=From:To:Subject:Date:From; b=IwtcJMXrKWk0UTv00zzZZIKcBm8kv63VIP32JCft144APjRduJqDkW+mAAARH8WRS OuZuYyUkUjPzRzTu+DwBKUm+NpfhIklRMHJEkKwUYGWnVWXD2xKZv7XGw8dIVwPOXY 58iBGjnHHjjj8olpDM/1r6w6Gktt6Ae+caaFyMuk= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: John Baldwin To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb.threads/multi-create: Double the existing stack size. X-Act-Checkin: binutils-gdb X-Git-Author: John Baldwin X-Git-Refname: refs/heads/master X-Git-Oldrev: 3625712636b1411d2b980217e7dd1ca8a4c8c502 X-Git-Newrev: 3c75f00adcea9d57c0d92669249dd884e49c4c3b Message-Id: <20230307005834.B2D913858C66@sourceware.org> Date: Tue, 7 Mar 2023 00:58:34 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D3c75f00adcea= 9d57c0d92669249dd884e49c4c3b commit 3c75f00adcea9d57c0d92669249dd884e49c4c3b Author: John Baldwin Date: Mon Mar 6 16:55:22 2023 -0800 gdb.threads/multi-create: Double the existing stack size. =20 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.t= hreads/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 =3D * (int *) arg; int j; =20 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); =20 /* 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; =20 pthread_attr_init (&attr); - pthread_attr_setstacksize (&attr, 2*PTHREAD_STACK_MIN); + pthread_attr_getstacksize (&attr, &stacksize); + pthread_attr_setstacksize (&attr, 2 * stacksize); =20 for (n =3D 0; n < 100; ++n) {