PG Bug reporting form <noreply@postgresql.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