Re: pgsql: Avoid crashing when a JIT-inlined backend function throws an err

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Amul Sul <sulamul(at)gmail(dot)com>
Cc: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: Re: pgsql: Avoid crashing when a JIT-inlined backend function throws an err
Date: 2024-07-11 14:42:15
Message-ID: 2077809.1720708935@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Amul Sul <sulamul(at)gmail(dot)com> writes:
> On Fri, Jun 28, 2024 at 12:14 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> 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

In response to

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2024-07-11 15:51:01 pgsql: Add min and max aggregates for composite types (records).
Previous Message Masahiko Sawada 2024-07-11 13:49:55 pgsql: Fix possibility of logical decoding partial transaction changes.