| From: | Michael Paquier <michael(at)paquier(dot)xyz> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: Tolerate partial pgstats entries in pgstat_gc_entry_refs() |
| Date: | 2026-09-17 10:26:49 |
| Message-ID: | E1x79KL-000000005xB-2Gli@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
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(dot)grigorev(at)ftdata(dot)ru>
Discussion: https://postgr.es/m/aqtiKTvl519bu8-V@paquier.xyz
Backpatch-through: 15
Branch
------
REL_18_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/e99e00b2751d3d4b5516d3c6243070da53ecad12
Modified Files
--------------
src/backend/utils/activity/pgstat_shmem.c | 9 +++++++++
1 file changed, 9 insertions(+)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Álvaro Herrera | 2026-09-17 10:48:03 | pgsql: Have the REPACK decoding worker use timeout values from the stee |
| Previous Message | Álvaro Herrera | 2026-09-17 09:47:14 | pgsql: Fix REPACK worker startup and shutdown sequences |