Re: v16dev: invalid memory alloc request size 8488348128

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Justin Pryzby <pryzby(at)telsasoft(dot)com>
Cc: David Rowley <dgrowleyml(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: v16dev: invalid memory alloc request size 8488348128
Date: 2023-04-16 16:26:28
Message-ID: 2199319.1681662388@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Justin Pryzby <pryzby(at)telsasoft(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2023-04-16 17:59:03 Re: Direct I/O
Previous Message Tom Lane 2023-04-16 16:16:25 Re: Direct I/O