pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Robert Haas <rhaas@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Switch memory contexts in ReinitializeParallelDSM.
Date: Tue, 16 Dec 2025 17:31:47 +0000
Message-ID: <E1vVYtm-0016DK-0A@gemulon.postgresql.org> (raw)

Switch memory contexts in ReinitializeParallelDSM.

We already do this in CreateParallelContext, InitializeParallelDSM, and
LaunchParallelWorkers. I suspect the reason why the matching logic was
omitted from ReinitializeParallelDSM is that I failed to realize that
any memory allocation was happening here -- but shm_mq_attach does
allocate, which could result in a shm_mq_handle being allocated in a
shorter-lived context than the ParallelContext which points to it.

That could result in a crash if the shorter-lived context is freed
before the parallel context is destroyed. As far as I am currently
aware, there is no way to reach a crash using only code that is
present in core PostgreSQL, but extensions could potentially trip
over this. Fixing this in the back-branches appears low-risk, so
back-patch to all supported versions.

Author: Jakub Wartak <jakub.wartak@enterprisedb.com>
Co-authored-by: Jeevan Chalke <jeevan.chalke@enterprisedb.com>
Backpatch-through: 14
Discussion: http://postgr.es/m/CAKZiRmwfVripa3FGo06=5D1EddpsLu9JY2iJOTgbsxUQ339ogQ@mail.gmail.com

Branch
------
REL_18_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/57df5ab8049782d7b24594ac677783512ffce2bc

Modified Files
--------------
src/backend/access/transam/parallel.c | 7 +++++++
1 file changed, 7 insertions(+)



view thread (6+ messages)  latest in thread

Message-ID: <E1vVYtm-0016DK-0A@gemulon.postgresql.org>
Permalink:  ../E1vVYtm-0016DK-0A@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1vVYtm-0016DK-0A@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 using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: rhaas@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Switch memory contexts in ReinitializeParallelDSM.
  In-Reply-To: <E1vVYtm-0016DK-0A@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