From: Justin Pryzby <pryzby@telsasoft.com>
To: David Rowley <dgrowleyml@gmail.com>
Cc: pgsql-hackers@postgresql.org, Tom Lane <tgl@sss.pgh.pa.us>
Subject: Re: v16dev: invalid memory alloc request size 8488348128
Date: Sat, 15 Apr 2023 18:19:04 -0500
Message-ID: <ZDsw6AcolRa+NGc6@telsasoft.com> (raw)
In-Reply-To: <CAApHDvq9HR1-SJfQP8+-tphmbABWzL6r87y92+UxKHz3yhqdqQ@mail.gmail.com>
References: <ZDm5TuKsh3tzoEjz@telsasoft.com>
<CAApHDvoBS2VryMzJRpp9AXeOiqoMLAry+3H=1Uf6-t+uMkGbMw@mail.gmail.com>
<ZDnYM8ONbQmKjxSO@telsasoft.com>
<CAApHDvq9HR1-SJfQP8+-tphmbABWzL6r87y92+UxKHz3yhqdqQ@mail.gmail.com>
On Sat, Apr 15, 2023 at 11:33:58AM +1200, David Rowley wrote:
> On Sat, 15 Apr 2023 at 10:48, Justin Pryzby <pryzby@telsasoft.com> wrote:
> >
> > On Sat, Apr 15, 2023 at 10:04:52AM +1200, David Rowley wrote:
> > > Which aggregate function is being called here? Is it a custom
> > > aggregate written in C, by any chance?
> >
> > That function is not an aggregate:
>
> There's an aggregate somewhere as indicated by this fragment from the
> stack trace:
>
> > #12 project_aggregates (aggstate=aggstate@entry=0x607200070d38) at ../src/backend/executor/nodeAgg.c:1377
> > #13 0x0000000000903eb6 in agg_retrieve_direct (aggstate=aggstate@entry=0x607200070d38) at ../src/backend/executor/nodeAgg.c:2520
> > #14 0x0000000000904074 in ExecAgg (pstate=0x607200070d38) at ../src/backend/executor/nodeAgg.c:2172
>
> Any chance you could try and come up with a minimal reproducer? You
> have access to see which aggregates are being used here and what data
> types are being given to them and then what's being done with the
> return value of that aggregate that's causing the crash. Maybe you
> can still get the crash if you mock up some data to aggregate and
> strip out the guts from the plpgsql functions that we're crashing on?
Try this
Attachments:postgresql-2023-04-14_202642.log.txt (text/plain, 722B) download
CREATE OR REPLACE FUNCTION avfinal(x anycompatiblearray) RETURNS anycompatiblearray
LANGUAGE plpgsql AS $$
DECLARE
res real[];
BEGIN
res := ARRAY_FILL(x[1], ARRAY[4]);
RETURN res;
END;
$$;
CREATE OR REPLACE FUNCTION acc(x anycompatiblearray, y anycompatiblearray) RETURNS anycompatiblearray
LANGUAGE plpgsql AS $$
BEGIN
RETURN ARRAY_FILL(y[1], ARRAY[4]);
END;
$$;
CREATE OR REPLACE AGGREGATE public.av(anycompatiblearray) (
STYPE = anycompatiblearray,
INITCOND = '{{0},{0}}',
SFUNC = acc,
FINALFUNC = avfinal
);
CREATE OR REPLACE FUNCTION aw(real[])
RETURNS void LANGUAGE plpgsql
AS $function$
begin
end
$function$;
SELECT
aw(av(ARRAY[1.0::real])),
aw(av(ARRAY[1.0::real])),
1;
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-hackers@postgresql.org
Cc: pryzby@telsasoft.com, dgrowleyml@gmail.com, tgl@sss.pgh.pa.us
Subject: Re: v16dev: invalid memory alloc request size 8488348128
In-Reply-To: <ZDsw6AcolRa+NGc6@telsasoft.com>
References: <ZDm5TuKsh3tzoEjz@telsasoft.com> <CAApHDvoBS2VryMzJRpp9AXeOiqoMLAry+3H=1Uf6-t+uMkGbMw@mail.gmail.com> <ZDnYM8ONbQmKjxSO@telsasoft.com> <CAApHDvq9HR1-SJfQP8+-tphmbABWzL6r87y92+UxKHz3yhqdqQ@mail.gmail.com> <ZDsw6AcolRa+NGc6@telsasoft.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox