shmem_startup_hook called twice on Windows

From: Sami Imseih <samimseih(at)gmail(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: shmem_startup_hook called twice on Windows
Date: 2025-08-15 14:17:22
Message-ID: CAA5RZ0vEGT1eigGbVt604LkXP6mUPMwPMxQoRCbFny44w+9EUQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

While working on a related area, I noticed that shmem_startup_hook
is called twice under EXEC_BACKEND.

The first call occurs in CreateSharedMemoryAndSemaphores() during
postmaster startup (!IsUnderPostmaster), which is expected.

The second call happens in AttachSharedMemoryStructs() (when
EXEC_BACKEND is defined), and this occurs in normal backends
(IsUnderPostmaster).

The second call does not seem correct. The startup hook that should
only run during
postmaster initialization, AFAIK.

Blame shows that this change was introduced in commit 69d903367c,
but I could not determine the rationale from the discussion,
so it may have been an oversight.

Thoughts?

--
Sami Imseih
Amazon Web Services (AWS)

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Marthin Laubscher 2025-08-15 15:01:44 About Custom Aggregates, C Extensions and Memory
Previous Message Burd, Greg 2025-08-15 13:58:09 Re: [PATCH] bms_prev_member() can read beyond the end of the array of allocated words