From: | Rider <oceanustz(at)gmail(dot)com> |
---|---|
To: | Steven Niu <niushiji(at)gmail(dot)com> |
Cc: | Michael Paquier <michael(at)paquier(dot)xyz>, Mikhail Kot <mikhail(dot)kot(at)databricks(dot)com>, "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>, "to(at)myrrc(dot)dev" <to(at)myrrc(dot)dev> |
Subject: | Re: 回复: Fix segfault while accessing half-initialized hash table in pgstat_shmem.c |
Date: | 2025-09-04 07:49:19 |
Message-ID: | CAKatu4tJe0PK-AsSmr0YYHsDYNrBC7AXeBgZQhEMnHZHvz-_uw@mail.gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi Steven,
I think when an error is thrown within the PG_TRY block, the assignment to
shheader is interrupted and never completes. As a result, shheader retains
its initial, NULL value.
And, the PG_RE_THROW() within the PG_CATCH block causes a non-local jump,
immediately aborting the current execution path to handle the error at a
higher level. This guarantees that the code following PG_END_TRY is
unreachable in the error scenario.
Steven Niu <niushiji(at)gmail(dot)com> 于2025年9月4日周四 15:38写道:
> _______________________________________
> From: Michael Paquier
> Sent: Thursday, September 04, 2025 14:30
> To: Steven Niu
> Cc: Mikhail Kot; pgsql-hackers(at)lists(dot)postgresql(dot)org; to(at)myrrc(dot)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".
>
From | Date | Subject | |
---|---|---|---|
Next Message | Richard Guo | 2025-09-04 08:21:10 | Re: plan shape work |
Previous Message | Andrei Klychkov | 2025-09-04 07:41:50 | Re: [PATCH] Fix ALTER SYSTEM empty string bug for GUC_LIST_QUOTE parameters |