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 1w6zuY-004rGm-2R for pgsql-bugs@arkaria.postgresql.org; Sun, 29 Mar 2026 23:51:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w6zuW-0002Kt-39 for pgsql-bugs@arkaria.postgresql.org; Sun, 29 Mar 2026 23:51:17 +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 1w6zuW-0002Kk-2L for pgsql-bugs@lists.postgresql.org; Sun, 29 Mar 2026 23:51:17 +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 1w6zuU-00000001tvk-1NO3 for pgsql-bugs@lists.postgresql.org; Sun, 29 Mar 2026 23:51:16 +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 62TNpCtq1881854; Sun, 29 Mar 2026 19:51:12 -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: 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 David Rowley message dated "Mon, 30 Mar 2026 12:41:37 +1300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1881852.1774828272.1@sss.pgh.pa.us> Date: Sun, 29 Mar 2026 19:51:12 -0400 Message-ID: <1881853.1774828272@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk David Rowley writes: > I looked at the code and tested. The only thing that I noted was > GenerationFree(), where we do: > /* Test for previously-freed chunk */ > if (unlikely(chunk->requested_size == InvalidAllocSize)) > elog(WARNING, "detected double pfree in %s %p", > ((MemoryContext) block->context)->name, chunk); > /* Test for someone scribbling on unused space in chunk */ > Assert(chunk->requested_size < chunksize); > I expect you've likely thought of this, but if we do spit out the > warning there, then the Assert is definitely going to fail, as > InvalidAllocSize is defined as SIZE_MAX. Yeah, I saw that after sending the patch. Not only would that Assert fail, but without it, code below would go nuts too. > I don't know if that means > it's worth deviating from the similar WARNINGs you've added and making > that one an ERROR. There's certainly no guarantee with the other > context that we'll not crash sometime very soon after issuing the > warning anyway, so maybe it's fine. Seems like a reasonable answer. What do you think of making the double-free cases ERRORs across the board? If we don't error out, there will likely be cascading problems in all the mcxt types not just this one. regards, tom lane