Re: BUG #16784: Server crash in ExecReScanAgg() - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #16784: Server crash in ExecReScanAgg()
Date
Msg-id 553495.1608578766@sss.pgh.pa.us
Whole thread Raw
In response to BUG #16784: Server crash in ExecReScanAgg()  (PG Bug reporting form <noreply@postgresql.org>)
Responses Re: BUG #16784: Server crash in ExecReScanAgg()
List pgsql-bugs
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



pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: Large objects and out-of-memory
Next
From: PG Bug reporting form
Date:
Subject: BUG #16785: Postgresql shutdown during initial pg_prewarm prewarming causes Pg to get stuck