Re: 回复: Fix segfault while accessing half-initialized hash table in pgstat_shmem.c

Michael Paquier <michael@paquier.xyz>

From: Michael Paquier <michael@paquier.xyz>
To: Steven Niu <niushiji@gmail.com>
Cc: Mikhail Kot <mikhail.kot@databricks.com>, "pgsql-hackers@lists.postgresql.org" <pgsql-hackers@lists.postgresql.org>, "to@myrrc.dev" <to@myrrc.dev>
Date: 2025-09-04T06:30:49Z
Lists: pgsql-hackers
On Thu, Sep 04, 2025 at 02:31:34AM +0000, Steven Niu wrote:
> If pgstat_init_entry() errors on OOM, what would it returns to shheader, NULL?
> That would bring trouble to dshash_delete_entry().

Based on the proposal of patch 0002, the code would throw an error
after cleaning up the shared memory state.  The generation and
refcount number assigned inside pgstat_init_entry() would not matter
as well because the entry created by dshash_find_or_insert() would be
entirely gone.  So I am not sure what's the point you are trying to
make here.
--
Michael

Commits

  1. Fix corruption of pgstats shared hashtable due to OOM failures