Re: v16dev: invalid memory alloc request size 8488348128 - Mailing list pgsql-hackers

From Tom Lane
Subject Re: v16dev: invalid memory alloc request size 8488348128
Date
Msg-id 2199319.1681662388@sss.pgh.pa.us
Whole thread Raw
In response to Re: v16dev: invalid memory alloc request size 8488348128  (Justin Pryzby <pryzby@telsasoft.com>)
List pgsql-hackers
Justin Pryzby <pryzby@telsasoft.com> writes:
> On Sat, Apr 15, 2023 at 11:33:58AM +1200, David Rowley wrote:
>> Any chance you could try and come up with a minimal reproducer?

> Try this

Thanks.  I see the problem: finalize_aggregate is no longer forcing
a R/W expanded datum returned by the finalfn into R/O form.  If
we re-use the aggregate result in multiple places, as this query
does, then the first use can clobber the value for later uses.
(The commit message specifically mentions this concern, so I wonder
how we failed to actually do it :-()

A minimal fix would be to force to R/O before returning from
finalize_aggregate, but I wonder if we should do it later.

By the by, I couldn't help noticing that ExecAggTransReparent
completely fails to do what its name promises it should do, ie
reparent a R/W datum into the proper context instead of physically
copying it.  That looks suspiciously like something that got broken
during some other refactoring somewhere along the line.  That'd be a
performance bug not a correctness bug, but it should be looked into.

            regards, tom lane



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Direct I/O
Next
From: Andrew Dunstan
Date:
Subject: Re: Direct I/O