agora inbox for pgsql-committers@postgresql.org  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Make GetSnapshotData() more resilient on out-of-memory errors
Date: Thu, 18 Jun 2026 05:14:16 +0000
Message-ID: <E1wa54y-000p5X-0o@gemulon.postgresql.org> (raw)

Make GetSnapshotData() more resilient on out-of-memory errors

If the allocation of Snapshot->subxip fails, a follow-up call of
GetSnapshotData() would see a partially-initialized snapshot, causing a
NULL dereference on reentry when using "subxip" because only "xip" would
be allocated.  In the event of an out-of-memory error when allocating
"subxip", "xip" is now reset before throwing an ERROR, so as Snapshots
can be allocated and handled gracefully on retry.

This problem is unlikely going to show up in practice, so no backpatch.

Reported-by: Alexander Lakhin <exclusion@gmail.com>
Author: Matthias van de Meent <boekewurm+postgres@gmail.com>
Discussion: https://postgr.es/m/e77acaac-a1b3-40b3-99ee-5769b4e453e4@gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/29fb598b9cad898ef851b9a7704f980218057562

Modified Files
--------------
src/backend/storage/ipc/procarray.c | 8 ++++++++
1 file changed, 8 insertions(+)



Message-ID: <E1wa54y-000p5X-0o@gemulon.postgresql.org>
Permalink:  ../E1wa54y-000p5X-0o@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1wa54y-000p5X-0o@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: michael@paquier.xyz, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Make GetSnapshotData() more resilient on out-of-memory errors
  In-Reply-To: <E1wa54y-000p5X-0o@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 agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox