Re: BUG #17798: Incorrect memory access occurs when using BEFORE ROW UPDATE trigger

From: Alexander Lakhin <exclusion(at)gmail(dot)com>
To: Richard Guo <guofenglinux(at)gmail(dot)com>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #17798: Incorrect memory access occurs when using BEFORE ROW UPDATE trigger
Date: 2023-04-20 10:00:00
Message-ID: f5ff446f-72e2-44f7-80c6-4256cf7caeb3@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hello Richard,

19.04.2023 11:29, Richard Guo wrote:
> I have a second look at this issue and now I think the fix in v1 patch
> is correct.  I think the comment needs to be updated for this change,
> maybe something like
>
>   * (Typically, newslot was also generated by ExecGetUpdateNewTuple, so
>   * that epqslot_clean will be that same slot and the copy step below
> - * is not needed.)
> + * is not needed.  And we need to materialize newslot in this case,
> + * since its tuple might be dependent on oldslot's storage, which
> + * might not be a local copy and be freed before we fetch newslot's
> + * tuple.)

Thanks for looking into this!

I've updated the comment based on your suggestion. Please look at the patch
attached.

I hesitate to add the isolation test to the patch as adding a dedicated
test just for this case seems too wasteful to me. Maybe that scenario could
be added to one of the existing trigger-related tests, but I couldn't find a
test, which is generic enough for that.

Best regards,
Alexander

Attachment Content-Type Size
v2-01-Fix-memory-access-in-BRU-trigger.patch text/x-patch 962 bytes

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Daniel Gustafsson 2023-04-20 11:15:40 Re: pg_basebackup: errors on macOS on directories with ".DS_Store" files
Previous Message Tobias Bussmann 2023-04-20 09:51:59 Re: pg_basebackup: errors on macOS on directories with ".DS_Store" files