Re: ExecAppendAsyncEventWait() in REL_14_STABLE can corrupt PG_exception_stack

From: Alexander Pyhalov <a(dot)pyhalov(at)postgrespro(dot)ru>
To: Etsuro Fujita <etsuro(dot)fujita(at)gmail(dot)com>
Cc: Michael Paquier <michael(at)paquier(dot)xyz>, Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: ExecAppendAsyncEventWait() in REL_14_STABLE can corrupt PG_exception_stack
Date: 2024-03-22 10:23:45
Message-ID: ea1cef7a33a97ca5a3e67d3f4ffde345@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Etsuro Fujita писал(а) 2024-03-21 13:59:
> On Sun, Feb 25, 2024 at 6:34 PM Etsuro Fujita <etsuro(dot)fujita(at)gmail(dot)com>
> wrote:
>
>> > On Fri, Feb 23, 2024 at 01:21:14PM +0300, Alexander Pyhalov wrote:
>> > > Recent commit 555276f8594087ba15e0d58e38cd2186b9f39f6d introduced final
>> > > cleanup of node->as_eventset in ExecAppendAsyncEventWait().
>> > > Unfortunately, now this function can return in the middle of TRY/FINALLY
>> > > block, without restoring PG_exception_stack.
>> > >
>> > > We found this while working on our FDW. Unfortunately, I couldn't reproduce
>> > > the issue with postgres_fdw, but it seems it is also affected.
>>
>> I think this would happen when FDWs configure no events; IIRC I think
>> while the core allows them to do so, postgres_fdw does not do so, so
>> this would never happen with it.
>
> I was wrong; as you pointed out, this would affect postgres_fdw as
> well. See commit 1ec7fca85, which is my commit, but I forgot it
> completely. :-(
>
> As I said before, the patch looks good to me. I tweaked comments in
> ExecAppendAsyncEventWait() a bit. Attached is an updated patch. In
> the patch I also fixed a confusing comment in a related function in
> postgres_fdw.c about handling of the in-process request that might be
> useless to process.
>
> Sorry, it took more time than expected to get back to this thread.
>

Hi. The updated patch still looks good to me.
--
Best regards,
Alexander Pyhalov,
Postgres Professional

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2024-03-22 10:26:23 Re: Introduce XID age and inactive timeout based replication slot invalidation
Previous Message Bharath Rupireddy 2024-03-22 10:14:13 Re: Support a wildcard in backtrace_functions