pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Allow callback functions to deregister themselves during a call.
Date: Wed, 28 Sep 2022 15:23:39 +0000
Message-ID: <E1odYuQ-002POU-VL@gemulon.postgresql.org> (raw)

Allow callback functions to deregister themselves during a call.

Fetch the next-item pointer before the call not after, so that
we aren't dereferencing a dangling pointer if the callback
deregistered itself during the call.  The risky coding pattern
appears in CallXactCallbacks, CallSubXactCallbacks, and
ResourceOwnerReleaseInternal.  (There are some other places that
might be at hazard if they offered deregistration functionality,
but they don't.)

I (tgl) considered back-patching this, but desisted because it
wouldn't be very safe for extensions to rely on this working in
pre-v16 branches.

Hao Wu

Discussion: https://postgr.es/m/CAH+9SWXTiERkmhRke+QCcc+jRH8d5fFHTxh8ZK0-Yn4BSpyaAg@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/4d2a844242dcfb34e05dd0d880b1a283a514b16b

Modified Files
--------------
src/backend/access/transam/xact.c     | 14 ++++++++++++--
src/backend/utils/resowner/resowner.c |  7 ++++++-
2 files changed, 18 insertions(+), 3 deletions(-)



Message-ID: <E1odYuQ-002POU-VL@gemulon.postgresql.org>
Permalink:  ../E1odYuQ-002POU-VL@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1odYuQ-002POU-VL@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Allow callback functions to deregister themselves during a call.
  In-Reply-To: <E1odYuQ-002POU-VL@gemulon.postgresql.org>
  References: <E1odYuQ-002POU-VL@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox