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.94.2) (envelope-from ) id 1sRv03-0021IW-Eb for pgsql-committers@arkaria.postgresql.org; Thu, 11 Jul 2024 14:42:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sRv00-00EnTm-Pt for pgsql-committers@arkaria.postgresql.org; Thu, 11 Jul 2024 14:42:20 +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.94.2) (envelope-from ) id 1sRv00-00EnT2-Hy for pgsql-committers@lists.postgresql.org; Thu, 11 Jul 2024 14:42:20 +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.94.2) (envelope-from ) id 1sRuzx-001ZcU-Ok for pgsql-committers@lists.postgresql.org; Thu, 11 Jul 2024 14:42:19 +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 46BEgFdv2077810; Thu, 11 Jul 2024 10:42:15 -0400 From: Tom Lane To: Amul Sul cc: pgsql-committers@lists.postgresql.org Subject: Re: pgsql: Avoid crashing when a JIT-inlined backend function throws an err In-reply-to: References: Comments: In-reply-to Amul Sul message dated "Thu, 11 Jul 2024 16:41:54 +0530" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <2077808.1720708935.1@sss.pgh.pa.us> Content-Transfer-Encoding: 8bit Date: Thu, 11 Jul 2024 10:42:15 -0400 Message-ID: <2077809.1720708935@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Amul Sul writes: > On Fri, Jun 28, 2024 at 12:14 AM Tom Lane wrote: >> Rather than fixing this by adding pstrdup() overhead to every >> elog/ereport sequence, let's fix it by copying the risky pointers >> in CopyErrorData(). That solves it for _SPI_commit/_SPI_rollback >> because they use that function to preserve the error data across >> the transaction end/restart sequence; and it seems likely that >> any other code doing something similar would need to do that too. > Should we make a similar change to ReThrowError() as well? I'm > particularly concerned about cases where someone might copy error data > using CopyErrorData() and then rethrowing that copied edata. I'd prefer not to propagate this kluge further than we provably have to. We've already created a memory leak with uncertain consequences in that FreeErrorData no longer reliably frees everything in the structure. Adding more copying steps makes that worse. So without demonstrable gain, I'd rather leave it alone. regards, tom lane