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

From Steven Niu
Subject Re: 回复: Fix segfault while accessing half-initialized hash table in pgstat_shmem.c
Date
Msg-id MN2PR15MB3021B920A3F445B1DE7D4904A700A@MN2PR15MB3021.namprd15.prod.outlook.com
Whole thread Raw
In response to Re: 回复: Fix segfault while accessing half-initialized hash table in pgstat_shmem.c  (Michael Paquier <michael@paquier.xyz>)
Responses Re: 回复: Fix segfault while accessing half-initialized hash table in pgstat_shmem.c
List pgsql-hackers
_______________________________________
From: Michael Paquier
Sent: Thursday, September 04, 2025 14:30
To: Steven Niu
Cc: Mikhail Kot; pgsql-hackers@lists.postgresql.org; to@myrrc.dev
Subject: Re: 回复: Fix segfault while accessing half-initialized hash table in pgstat_shmem.c

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


Sorry, I made a mistake. I should say:
"If pgstat_init_entry() errors on OOM, the local variable shheader may be NULL. This would bring trouble to
pgstat_acquire_entry_ref()in the line 30 of patch 002".  

pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: Fix segfault while accessing half-initialized hash table in pgstat_shmem.c
Next
From: Andrei Klychkov
Date:
Subject: Re: [PATCH] Fix ALTER SYSTEM empty string bug for GUC_LIST_QUOTE parameters