agora inbox for pgsql-committers@postgresql.org
help / color / mirror / Atom feedFrom: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Tolerate partial pgstats entries in pgstat_gc_entry_refs()
Date: Thu, 17 Sep 2026 10:26:49 +0000
Message-ID: <E1x79KL-000000005xH-2Yjm@gemulon.postgresql.org> (raw)
Tolerate partial pgstats entries in pgstat_gc_entry_refs()
pgstat_get_entry_ref_cached() inserts a local entry_ref with
shmem-related fields set to NULL, expecting pgstat_get_entry_ref() (its
sole caller) to fill them up before returning. If an ERROR happens
while pgstat_get_entry_ref() runs, it could be possible to finish with a
local pgstats entry partially filled.
This could lead to a crash of pgstat_gc_entry_refs(), which tolerates a
NULL shared_stats in an assertion but unconditionally dereferenced its
"dropped" and "generation" fields.
This extends 4069df21beb8, being a cheap insurance against NULL pointer
dereference, if some code paths of pgstat_get_entry_ref() are not able
to perform any cleanup actions (for example after a dsm_create()
throwing an ERROR).
Reviewed-by: Grigorev Jurij <ju.grigorev@ftdata.ru>
Discussion: https://postgr.es/m/aqtiKTvl519bu8-V@paquier.xyz
Backpatch-through: 15
Branch
------
REL_15_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/0016a2cc4fda8415ed524ad8645325fab7433273
Modified Files
--------------
src/backend/utils/activity/pgstat_shmem.c | 9 +++++++++
1 file changed, 9 insertions(+)
view thread (6+ messages)
Message-ID: <E1x79KL-000000005xH-2Yjm@gemulon.postgresql.org>
Permalink: ../E1x79KL-000000005xH-2Yjm@gemulon.postgresql.org/
Also on: postgresql.org/message-id/E1x79KL-000000005xH-2Yjm@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: Tolerate partial pgstats entries in pgstat_gc_entry_refs()
In-Reply-To: <E1x79KL-000000005xH-2Yjm@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