Re: array_agg(DISTINCT) caused a segmentation fault

From: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>
To: David Rowley <dgrowleyml(at)gmail(dot)com>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: array_agg(DISTINCT) caused a segmentation fault
Date: 2023-02-13 09:03:58
Message-ID: 43ad904c-8e62-a96f-91d7-b4894a433e20@oss.nttdata.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On 2023/02/13 16:44, David Rowley wrote:
> On Mon, 13 Feb 2023 at 18:29, Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com> wrote:
>> =# SELECT array_agg(distinct val) FROM (SELECT NULL AS val FROM generate_series(1, 2)) hoge;
>> LOG: server process (PID 76507) was terminated by signal 11: Segmentation fault: 11
>> DETAIL: Failed process was running: SELECT array_agg(distinct val) FROM (SELECT NULL AS val FROM generate_series(1, 2)) hoge;
>
> This was a fairly trivial logic bug in
> ExecEvalPreOrderedDistinctSingle(). The JIT code calls that same
> function and ExecEvalPreOrderedDistinctMulti() uses the standard
> expression evaluation logic. So looks like the problem is just
> isolated to ExecEvalPreOrderedDistinctSingle().
>
> I've now pushed a fix for it and included your test. To get it to
> crash it needed to be a byref aggregate without a strict transition
> function. There are not too many of those, which is probably why
> nobody noticed this before.

Thanks for the fix!

Regards,

--
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2023-02-13 09:21:52 BUG #17790: Download of SLES 12 SP5 - x86_64 is not working
Previous Message David Rowley 2023-02-13 07:44:02 Re: array_agg(DISTINCT) caused a segmentation fault