Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1krQp0-0001Xs-9v for pgsql-bugs@arkaria.postgresql.org; Mon, 21 Dec 2020 19:26:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1krQoy-0001vq-Nw for pgsql-bugs@arkaria.postgresql.org; Mon, 21 Dec 2020 19:26:16 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1krQoy-0001vj-I3 for pgsql-bugs@lists.postgresql.org; Mon, 21 Dec 2020 19:26:16 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1krQos-0007Kd-AJ for pgsql-bugs@lists.postgresql.org; Mon, 21 Dec 2020 19:26:15 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 0BLJQ6ND553496; Mon, 21 Dec 2020 14:26:07 -0500 From: Tom Lane To: exclusion@gmail.com cc: pgsql-bugs@lists.postgresql.org, Jeff Davis Subject: Re: BUG #16784: Server crash in ExecReScanAgg() In-reply-to: <16784-7ff169bf2c3d1588@postgresql.org> References: <16784-7ff169bf2c3d1588@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Mon, 21 Dec 2020 17:00:01 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <553494.1608578766.1@sss.pgh.pa.us> Date: Mon, 21 Dec 2020 14:26:06 -0500 Message-ID: <553495.1608578766@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk PG Bug reporting form writes: > The following query (borrowed from regression tests): > ... > leads to a server crash with the following stacktrace: Duplicated here. > The first bad commit is 2fd6a44a. I suspect the culprit is 1f39bce02 (but it's still Jeff's fault ;-)). What I see happening is that the second time through ExecReScanAgg crashes here: MemSet(node->pergroups[setno], 0, sizeof(AggStatePerGroupData) * node->numaggs); because node->pergroups[0] is now NULL, which is the fault of this bit in agg_refill_hash_table: /* there could be residual pergroup pointers; clear them */ for (int setoff = 0; setoff < aggstate->maxsets + aggstate->num_hashes; setoff++) aggstate->all_pergroups[setoff] = NULL; I suspect this is clearing the wrong subset of the all_pergroups pointers, but the code is so underdocumented that I'm not very sure. regards, tom lane