Re: [Bug] Heap Use After Free in Window Aggregate Execution

David Rowley <dgrowleyml@gmail.com>

From: David Rowley <dgrowleyml@gmail.com>
To: Jayesh Dehankar <jayesh.dp@zohocorp.com>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>, "zlabs-cstore@zohocorp.com" <zlabs-cstore@zohocorp.com>, pgsql-hackers <pgsql-hackers@lists.postgresql.org>, pgsql-bugs <pgsql-bugs@lists.postgresql.org>
Date: 2024-12-09T01:28:26Z
Lists: pgsql-bugs, pgsql-hackers
On Thu, 14 Nov 2024 at 04:31, Jayesh Dehankar <jayesh.dp@zohocorp.com> wrote:
> We have discovered a bug in PostgreSQL v16.3 related to a top-level window aggregate with a partition-by clause. The issue occurs when the run condition fails, causing the window aggregate status to change from WINDOWAGG_RUN to WINDOWAGG_PASSTHROUGH_STRICT mode. The bug is present in the latest STABLE branch.

> 2) Execute below SQL queries:
> create table issue(a int, f text);
> insert into issue values (1, 'aa'), (1, 'bb');
> select * from ( select row_number() over (partition by a) as first, lead(f) over (partition by a) as third from issue) emp where first < 1;

Thank you for the detailed report and reproducer.

I've pushed a fix for this issue. It should be available in the 16.7
release around mid-Feb 2025.

David



Commits

  1. Fix possible crash during WindowAgg evaluation

  2. Add missing word in comment