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

2025-09-08 Thread Michael Paquier
On Sat, Sep 06, 2025 at 10:01:24AM +0900, Michael Paquier wrote: > A last thing that I was not able to spend much time on is how much it > is possible to mess up with the shared memory state. If it is worse > than I suspected initially, where an OOM in a first session can cause > crashes because o

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

2025-09-07 Thread Steven Niu
___ From: Michael Paquier Sent: Thursday, September 04, 2025 14:30 To: Steven Niu Cc: Mikhail Kot; pgsql-hackers@lists.postgresql.org; t...@myrrc.dev Subject: Re: 回复: Fix segfault while accessing half-initialized hash table in pgstat_shmem.c On Thu, Sep 04

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

2025-09-05 Thread Michael Paquier
On Thu, Sep 04, 2025 at 03:49:19PM +0800, Rider wrote: > 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 er

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

2025-09-05 Thread Michael Paquier
On Fri, Sep 05, 2025 at 09:46:55PM +0100, Mikhail Kot wrote: > Do you want me to update the patch based on your suggestion on fault > injection, or update the try/catch to the callers as discussed, or > it's good to be included in Postgres? I would prefer the approach of letting the callers deal w

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

2025-09-05 Thread Mikhail Kot
Hi, Do you want me to update the patch based on your suggestion on fault injection, or update the try/catch to the callers as discussed, or it's good to be included in Postgres?

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

2025-09-04 Thread Michael Paquier
On Thu, Sep 04, 2025 at 02:31:34AM +, 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 s

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

2025-09-04 Thread Rider
; To: Steven Niu > Cc: Mikhail Kot; pgsql-hackers@lists.postgresql.org; t...@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 +, Steven Niu wrote: > > If pgstat_init_entry() errors

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

2025-09-03 Thread Steven Niu
Hi, Mikhail, If pgstat_init_entry() errors on OOM, what would it returns to shheader, NULL? That would bring trouble to dshash_delete_entry(). Thanks, Steven 发件人: Mikhail Kot 已发送: 2025 年 9 月 04 日 星期四 05:39 收件人: pgsql-hackers@lists.postgresql.org 抄送: t...@myrrc

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

2025-09-03 Thread Steven Niu
发件人: Michael Paquier 已发送: 2025 年 9 月 03 日 星期三 17:43 收件人: Steven Niu 抄送: Mikhail Kot; pgsql-hackers@lists.postgresql.org; t...@myrrc.dev 主题: Re: 回复: Fix segfault while accessing half-initialized hash table in pgstat_shmem.c On Wed, Sep 03, 2025 at 07:22

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

2025-09-03 Thread Michael Paquier
On Wed, Sep 03, 2025 at 07:22:00AM +, Steven Niu wrote: > So unless dsa_allocate() can ensure never returns InvalidDsaPointer, > there is risk of SegV. In fact the function dsa_allocate() does > return InvalidDsaPointer in some cases. > > So, maybe should we add pointer check in all places wh

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

2025-09-03 Thread Steven Niu
I found there are many cases of following pattern: ptr_1 = dsa_allocate(); ptr_2 = dsa_get_address(xxx, ptr_1); ptr_2->yyy = zzz; Inside dsa_get_address(dsa_area *area, dsa_pointer dp):   /* Convert InvalidDsaPointer to NULL. */   if (!DsaPointerIsValid(dp)) return NULL; So