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 1mtbGh-00084r-5z for pgsql-general@arkaria.postgresql.org; Sat, 04 Dec 2021 20:04:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mtbGf-0006fu-NM for pgsql-general@arkaria.postgresql.org; Sat, 04 Dec 2021 20:04:21 +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 1mtbGf-0006fl-Ct for pgsql-general@lists.postgresql.org; Sat, 04 Dec 2021 20:04:21 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mtbGb-00051z-1R for pgsql-general@lists.postgresql.org; Sat, 04 Dec 2021 20:04:20 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 1B4K4FYp2693284; Sat, 4 Dec 2021 15:04:15 -0500 From: Tom Lane To: Matt Magoffin cc: pgsql-general@lists.postgresql.org Subject: Re: Handling memory contexts in aggregate function invoking other built-in aggregate functions In-reply-to: <5514A57A-967F-451A-BE04-58D97AC6480B@msqr.us> References: <2643578.1638634565@sss.pgh.pa.us> <5514A57A-967F-451A-BE04-58D97AC6480B@msqr.us> Comments: In-reply-to Matt Magoffin message dated "Sun, 05 Dec 2021 06:56:07 +1300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2693282.1638648255.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sat, 04 Dec 2021 15:04:15 -0500 Message-ID: <2693283.1638648255@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Matt Magoffin writes: > On 5/12/2021, at 5:16 AM, Tom Lane wrote: >> Are you testing in an --enable-cassert build? If not, do that; >> it might make the cause of the crashes more apparent, thanks to >> CLOBBER_FREED_MEMORY and other debug support. > I did build with --enable-cassert, and I did see the state argument poin= ter passed to numeric_avg_accum > as 0x7f7f7f7f7f, so now I understand why that was thanks to seeing the = information about what that means on the Dev FAQ, thanks for that. So that probably means that you weren't careful about allocating your own state data in the long-lived context (agg_context), and so it got freed between calls. regards, tom lane