Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w6sxM-004kcO-1e for pgsql-bugs@arkaria.postgresql.org; Sun, 29 Mar 2026 16:25:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w6sxK-00Gdzs-0P for pgsql-bugs@arkaria.postgresql.org; Sun, 29 Mar 2026 16:25:42 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w6sxJ-00Gdzk-2n for pgsql-bugs@lists.postgresql.org; Sun, 29 Mar 2026 16:25:42 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1w6sxH-00000001qdP-2obO for pgsql-bugs@lists.postgresql.org; Sun, 29 Mar 2026 16:25:42 +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 62TGPcQ21835963; Sun, 29 Mar 2026 12:25:38 -0400 From: Tom Lane To: David Rowley cc: kuzmin.db4@gmail.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #19438: segfault with temp_file_limit inside cursor In-reply-to: <1830345.1774798374@sss.pgh.pa.us> References: <19438-9d37b179c56d43aa@postgresql.org> <1106026.1774573371@sss.pgh.pa.us> <1338824.1774633289@sss.pgh.pa.us> <1830345.1774798374@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Sun, 29 Mar 2026 11:32:54 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1835961.1774801537.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sun, 29 Mar 2026 12:25:38 -0400 Message-ID: <1835962.1774801538@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk I wrote: > ... I don't think alignedalloc.c > needs its own defense either: it can rely on the underlying > context type. I started to wonder if an explicit test in AlignedAllocFree could be useful anyway to make such problems a bit less obscure. However, when I tried p =3D palloc_aligned(...); pfree(p); pfree(p); I got ERROR: pfree called with invalid pointer 0x1f286b0 (header 0x7f7f7f7f7f7f= 7f7f) That is, we'll never get to AlignedAllocFree because the underlying context would have wipe_mem'd the aligned chunk's header during the first pfree. The only case in which such a test could be helpful is in a build with MEMORY_CONTEXT_CHECKING but not CLOBBER_FREED_MEMORY. While I suppose some people might build that way, it's got to be such a tiny minority as to not be worth worrying about. regards, tom lane