Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pRUkp-0000tz-9d for pgsql-bugs@arkaria.postgresql.org; Mon, 13 Feb 2023 09:04:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pRUkn-0005Vz-OC for pgsql-bugs@arkaria.postgresql.org; Mon, 13 Feb 2023 09:04:05 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pRUkn-0005Vq-FU for pgsql-bugs@lists.postgresql.org; Mon, 13 Feb 2023 09:04:05 +0000 Received: from oss.nttdata.com ([49.212.34.109]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pRUkk-0007vZ-Vd for pgsql-bugs@lists.postgresql.org; Mon, 13 Feb 2023 09:04:04 +0000 Received: from [172.20.10.7] (sp49-97-94-180.msc.spmode.ne.jp [49.97.94.180]) by oss.nttdata.com (Postfix) with ESMTPSA id 0109B609D4; Mon, 13 Feb 2023 18:03:58 +0900 (JST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.7 at oss.nttdata.com Message-ID: <43ad904c-8e62-a96f-91d7-b4894a433e20@oss.nttdata.com> Date: Mon, 13 Feb 2023 18:03:58 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.7.2 Subject: Re: array_agg(DISTINCT) caused a segmentation fault To: David Rowley Cc: pgsql-bugs@lists.postgresql.org References: <860c6d6f-a3c5-3ae9-9da2-827177bede06@oss.nttdata.com> Content-Language: en-US From: Fujii Masao In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2023/02/13 16:44, David Rowley wrote: > On Mon, 13 Feb 2023 at 18:29, Fujii Masao 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