From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.baldwin.cx (bigwig.baldwin.cx [IPv6:2607:f138:0:13::2]) by sourceware.org (Postfix) with ESMTPS id 4FEF138582AB for ; Fri, 17 Feb 2023 20:38:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4FEF138582AB Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=FreeBSD.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=FreeBSD.org Received: from gimli.baldwin.net (c-98-35-126-114.hsd1.ca.comcast.net [98.35.126.114]) by mail.baldwin.cx (Postfix) with ESMTPSA id A5B2A1A84C54 for ; Fri, 17 Feb 2023 15:38:24 -0500 (EST) From: John Baldwin 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 Message-Id: <20230217203818.11287-2-jhb@FreeBSD.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230217203818.11287-1-jhb@FreeBSD.org> References: <20230217203818.11287-1-jhb@FreeBSD.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.6.4 (mail.baldwin.cx [0.0.0.0]); Fri, 17 Feb 2023 15:38:24 -0500 (EST) X-Virus-Scanned: clamav-milter 0.103.1 at mail.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00,FORGED_SPF_HELO,GIT_PATCH_0,KAM_DMARC_STATUS,KHOP_HELO_FCRDNS,SPF_HELO_PASS,SPF_SOFTFAIL,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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