| From: | Mikhail Kot <mikhail(dot)kot(at)databricks(dot)com> |
|---|---|
| To: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
| Cc: | to(at)myrrc(dot)dev |
| Subject: | Re: Fix segfault while accessing half-initialized hash table in pgstat_shmem.c |
| Date: | 2025-09-03 21:39:04 |
| Message-ID: | CAAi9E7ge4APjZ_atDce+qjYODnxuRwmNej-9RhL3Ydi3zRs8bw@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi Michael, Steven, and Ranier,
> Anyway, couldn't we flip the order of the operations in
pgstat_init_entry() so as we do first an allocation and avoid any inconsistency
in the shared state?
The issue is not only in pgstat_init_entry(). Currently it errors on OOM but
this doesn't prevent us from calling pgstat_lock_entry() through
pgstat_get_entry_ref() which accesses a non-initialized lock.
Here's the second version of the patch. Now we remove inserted hash entry
on OOM which would prevent accessing the entry
| Attachment | Content-Type | Size |
|---|---|---|
| 0002-fix-sshashent-access-segfault-when-it-s-half-initial.patch | application/octet-stream | 1.1 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Thomas Munro | 2025-09-03 21:56:22 | Re: Solaris compiler status |
| Previous Message | Nathan Bossart | 2025-09-03 21:36:47 | Re: GetNamedLWLockTranche crashes on Windows in normal backend |