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 <[email protected]> Discussion: https://postgr.es/m/[email protected] Backpatch-through: 15 Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/16706f1f4dc202d502f07f7b14bb600eb0daef92 Modified Files -------------- src/backend/utils/activity/pgstat_shmem.c | 9 +++++++++ 1 file changed, 9 insertions(+)
