Re: BUG #16784: Server crash in ExecReScanAgg()

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: exclusion(at)gmail(dot)com
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org, Jeff Davis <pgsql(at)j-davis(dot)com>
Subject: Re: BUG #16784: Server crash in ExecReScanAgg()
Date: 2020-12-21 19:26:06
Message-ID: 553495.1608578766@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

PG Bug reporting form <noreply(at)postgresql(dot)org> 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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2020-12-21 21:15:24 BUG #16785: Postgresql shutdown during initial pg_prewarm prewarming causes Pg to get stuck
Previous Message Stephen Frost 2020-12-21 19:13:39 Re: BUG #16079: Question Regarding the BUG #16064