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

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Make GetSnapshotData() more resilient on out-of-memory errors
Date: 2026-06-18 05:14:16
Message-ID: E1wa54y-000p5X-0o@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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(at)gmail(dot)com>
Author: Matthias van de Meent <boekewurm+postgres(at)gmail(dot)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(+)

Browse pgsql-committers by date

  From Date Subject
Next Message Michael Paquier 2026-06-18 05:49:22 pgsql: Update .abi-compliance-history for pgstat_drop_entry()
Previous Message Amit Kapila 2026-06-18 04:27:19 pgsql: Avoid stale slot access after dropping obsolete synced slots.