pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
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, 12 Nov 2026 06:01:38 +0000
Message-ID: <E1xRNsQ-00000000OyW-0xbZ@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.

Note: This has been originally applied in v19~ as of 29fb598b9cad, and
was initially not backpatched.  This issue has been seen in the field on
older stable branches, hence the backpatch now.

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
Discussion: https://postgr.es/m/CAJ7c6TO+7rrN5H_Odd8PLdmrEa4MgeoJ2AqnTydOcy=AyZvDsQ@mail.gmail.com
Backpatch-through: 15

Branch
------
REL_18_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/94641eda4c6293fa43b44ff8c7433b510f4bcfa5

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



view thread (8+ messages)  latest in thread

Message-ID: <E1xRNsQ-00000000OyW-0xbZ@gemulon.postgresql.org>
Permalink:  ../E1xRNsQ-00000000OyW-0xbZ@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1xRNsQ-00000000OyW-0xbZ@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: michael@paquier.xyz
  Subject: Re: pgsql: Make GetSnapshotData() more resilient on out-of-memory errors
  In-Reply-To: <E1xRNsQ-00000000OyW-0xbZ@gemulon.postgresql.org>
  References: <E1xRNsQ-00000000OyW-0xbZ@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