Re: Use-after-free in reorderbuffer.c for INSERT ON CONFLICT

Masahiko Sawada <sawada.mshk@gmail.com>

From: Masahiko Sawada <sawada.mshk@gmail.com>
To: Michael Paquier <michael@paquier.xyz>
Cc: Postgres bugs <pgsql-bugs@lists.postgresql.org>, Amit Kapila <amit.kapila16@gmail.com>, Ethan Mertz <ethan.mertz@gmail.com>
Date: 2025-07-31T16:51:21Z
Lists: pgsql-bugs

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Fix use-after-free with INSERT ON CONFLICT changes in reorderbuffer.c

On Wed, Jul 30, 2025 at 11:44 PM Michael Paquier <michael@paquier.xyz> wrote:
>
> A simple solution suggested by Ethan would be to use the "prev_lsn"
> guessed from the change at the beginning of the loop, rather than the
> problematic change->lsn.  But that does not seem completely right to
> me because we can switch to "specinsert" as the change to process,
> hence wouldn't we want to call update_progress_txn() based on the LSN
> of the actual change we are looking at?  All that leads me to the
> attached.

Thank you for preparing the patch!

Yes, I think it's sensible to keep the current behavior. So the patch
looks good to me.

Regards,

-- 
Masahiko Sawada
Amazon Web Services: https://aws.amazon.com