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

From Tom Lane
Subject Re: pgsql: Avoid crashing when a JIT-inlined backend function throws an err
Date
Msg-id 2077809.1720708935@sss.pgh.pa.us
Whole thread Raw
In response to Re: pgsql: Avoid crashing when a JIT-inlined backend function throws an err  (Amul Sul <sulamul@gmail.com>)
List pgsql-committers
Amul Sul <sulamul@gmail.com> writes:
> On Fri, Jun 28, 2024 at 12:14 AM Tom Lane <tgl@sss.pgh.pa.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



pgsql-committers by date:

Previous
From: Masahiko Sawada
Date:
Subject: pgsql: Fix possibility of logical decoding partial transaction changes.
Next
From: Tom Lane
Date:
Subject: pgsql: Add min and max aggregates for composite types (records).