Re: Missing initialization steps in --check and --single modes

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Missing initialization steps in --check and --single modes
Date: 2024-12-17 02:11:05
Message-ID: 2144139.1734401465@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I wrote:
> While comparing bootstrap.c to postmaster.c, I also noticed that
> bootstrap mode is failing to call set_stack_base(). That means that
> our checks for stack overflow are inoperative in bootstrap mode,
> which doesn't seem great.
> The same omissions appear in PostgresSingleUserMain, meaning that
> --single mode also operates with few FDs and no stack depth
> protection. That's considerably less than great.

Actually ... instead of calling set_stack_base() in more places,
how about we call it in fewer? I see no reason why we can't have
a single call site in the backend's main() function. This ensures
across-the-board coverage without fear of future omissions, and it
gives a more consistent reference point than the existing code.
(That point will be a few bytes more conservative than what we
are doing now, but that seems fine.)

I'm very tempted to move set_stack_base() and related functions
and variables out of postgres.c altogether, except I'm not sure
where they should go. main.c doesn't quite feel like the right
place.

See attached, which doesn't address the set_max_safe_fds() issue.
That has to run after CreateSharedMemoryAndSemaphores(), so there
probably isn't a better answer than to call it after each such call.
(I guess we could call it *in* CreateSharedMemoryAndSemaphores, but
that feels outside the charter of that function.)

regards, tom lane

Attachment Content-Type Size
v1-move-stack-base-setting.patch text/x-diff 2.0 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robins Tharakan 2024-12-17 02:54:49 Re: Cutting support for OpenSSL 1.0.1 and 1.0.2 in 17~?
Previous Message Richard Guo 2024-12-17 00:56:13 Re: Eager aggregation, take 3