Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iJRQQ-0006My-44 for pgsql-hackers@arkaria.postgresql.org; Sun, 13 Oct 2019 00:07:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iJRPO-0007Az-IQ for pgsql-hackers@arkaria.postgresql.org; Sun, 13 Oct 2019 00:06:50 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iJRPO-0007AU-85 for pgsql-hackers@lists.postgresql.org; Sun, 13 Oct 2019 00:06:50 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iJRPG-00072Z-9p for pgsql-hackers@postgresql.org; Sun, 13 Oct 2019 00:06:48 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x9D06Wp5025034; Sat, 12 Oct 2019 20:06:32 -0400 From: Tom Lane To: Thomas Munro cc: Andrew Dunstan , Mark Wong , Justin Pryzby , Andres Freund , pgsql-hackers Subject: Re: stress test for parallel workers In-reply-to: <17884.1570915552@sss.pgh.pa.us> References: <20190723162703.GM22387@telsasoft.com> <6762.1563902927@sss.pgh.pa.us> <20190723174222.GO22387@telsasoft.com> <32179.1563919918@sss.pgh.pa.us> <17389.1563945314@sss.pgh.pa.us> <31032.1565152159@sss.pgh.pa.us> <18537.1570421268@sss.pgh.pa.us> <5350.1570743291@sss.pgh.pa.us> <84813a30-8c34-9c32-7ad5-90d9eefba468@2ndQuadrant.com> <06d6be5a-7af2-ef78-0abc-6bfe500ead87@2ndQuadrant.com> <20032.1570808731@sss.pgh.pa.us> <14878.1570820201@sss.pgh.pa.us> <18266.1570824826@sss.pgh.pa.us> <21051.1570828384@sss.pgh.pa.us> <17884.1570915552@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Sat, 12 Oct 2019 17:25:52 -0400" MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0" Content-ID: <24942.1570925055.0@sss.pgh.pa.us> Date: Sat, 12 Oct 2019 20:06:32 -0400 Message-ID: <25033.1570925192@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk ------- =_aaaaaaaaaa0 Content-Type: text/plain; charset="us-ascii" Content-ID: <24942.1570925055.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable I wrote: > In short, my current belief is that Linux PPC64 fails when trying > to deliver a signal if there's right around 2KB of stack remaining, > even though it should be able to expand the stack and press on. I figured I should try to remove some variables from the equation by demonstrating this claim without involving Postgres. The attached test program eats some stack space and then waits to be sent SIGUSR1. For some values of "some stack space", it dumps core: [tgl@postgresql-fedora ~]$ gcc -g -Wall -O1 stacktest.c [tgl@postgresql-fedora ~]$ ./a.out 1240000 & [1] 11796 [tgl@postgresql-fedora ~]$ kill -USR1 11796 [tgl@postgresql-fedora ~]$ signal delivered, stack base 0x7fffdc160000 top= 0x7fffdc031420 (1240032 used) [1]+ Done ./a.out 1240000 [tgl@postgresql-fedora ~]$ ./a.out 1242000 & [1] 11797 [tgl@postgresql-fedora ~]$ kill -USR1 11797 [tgl@postgresql-fedora ~]$ = [1]+ Segmentation fault (core dumped) ./a.out 1242000 [tgl@postgresql-fedora ~]$ uname -a Linux postgresql-fedora.novalocal 4.18.19-100.fc27.ppc64le #1 SMP Wed Nov = 14 21:53:32 UTC 2018 ppc64le ppc64le ppc64le GNU/Linux I don't think any further proof is required that this is a kernel bug. Where would be a good place to file it? regards, tom lane ------- =_aaaaaaaaaa0 Content-Type: text/x-c; name="stacktest.c"; charset="us-ascii" Content-ID: <24942.1570925055.2@sss.pgh.pa.us> Content-Description: stacktest.c #include #include #include #include static char *stack_base_ptr; static char *stack_top_ptr; static volatile sig_atomic_t sig_occurred = 0; static void sigusr1_handler(int signal_arg) { sig_occurred = 1; } static void consume_stack(long stackdepth) { char stack_cur; if ((stack_base_ptr - &stack_cur) < stackdepth) consume_stack(stackdepth); else { stack_top_ptr = &stack_cur; while (!sig_occurred) ; } } int main(int argc, char **argv) { long stackdepth = atol(argv[1]); char stack_base; struct sigaction act; act.sa_handler = sigusr1_handler; sigemptyset(&act.sa_mask); act.sa_flags = 0; if (sigaction(SIGUSR1, &act, NULL) < 0) perror("sigaction"); stack_base_ptr = (char *) (((size_t) &stack_base + 65535) & ~65535UL); consume_stack(stackdepth); if (sig_occurred) printf("signal delivered, stack base %p top %p (%zu used)\n", stack_base_ptr, stack_top_ptr, stack_base_ptr - stack_top_ptr); else printf("no signal delivered\n"); return 0; } ------- =_aaaaaaaaaa0--