Re: common signal handler protection

2024-02-14 Thread Nathan Bossart
On Wed, Feb 14, 2024 at 11:55:43AM -0800, Noah Misch wrote: > I took a look over each of these. +1 for all. Thank you. Committed. Thanks! -- Nathan Bossart Amazon Web Services: https://aws.amazon.com

Re: common signal handler protection

2024-02-14 Thread Noah Misch
On Mon, Dec 18, 2023 at 11:32:47AM -0600, Nathan Bossart wrote: > rebased for cfbot I took a look over each of these. +1 for all. Thank you.

Re: common signal handler protection

2024-02-07 Thread Nathan Bossart
On Wed, Feb 07, 2024 at 10:40:50AM -0800, Andres Freund wrote: > On 2024-02-07 11:15:54 -0600, Nathan Bossart wrote: >> Perhaps we should add a file global bool that is only set during >> wrapper_handler(). Then we could Assert() or elog(ERROR, ...) if >> pqsignal() is called with it set. > > In

Re: common signal handler protection

2024-02-07 Thread Andres Freund
Hi, On 2024-02-07 11:15:54 -0600, Nathan Bossart wrote: > On Wed, Feb 07, 2024 at 11:06:50AM -0600, Nathan Bossart wrote: > > I'd like to get this committed (to HEAD only) in the next few weeks. TBH > > I'm not wild about the weird caveats (e.g., race conditions when pqsignal() > > is called

Re: common signal handler protection

2024-02-07 Thread Nathan Bossart
Sorry for the noise. On Wed, Feb 07, 2024 at 11:06:50AM -0600, Nathan Bossart wrote: > I'd like to get this committed (to HEAD only) in the next few weeks. TBH > I'm not wild about the weird caveats (e.g., race conditions when pqsignal() > is called within a signal handler), but I also think it

Re: common signal handler protection

2024-02-07 Thread Nathan Bossart
On Tue, Feb 06, 2024 at 06:48:53PM -0800, Andres Freund wrote: > On 2024-02-06 20:39:41 -0600, Nathan Bossart wrote: >> I finally spent some time trying to measure this overhead. Specifically, I >> sent many, many SIGUSR2 signals to postmaster, which just uses >> dummy_handler(), i.e., does

Re: common signal handler protection

2024-02-06 Thread Andres Freund
Hi, On 2024-02-06 20:39:41 -0600, Nathan Bossart wrote: > On Tue, Nov 21, 2023 at 03:20:08PM -0600, Nathan Bossart wrote: > > * Overhead: The wrapper handler calls a function pointer and getpid(), > > which AFAICT is a real system call on most platforms. That might not be > > a tremendous

Re: common signal handler protection

2024-02-06 Thread Nathan Bossart
On Tue, Nov 21, 2023 at 03:20:08PM -0600, Nathan Bossart wrote: > * Overhead: The wrapper handler calls a function pointer and getpid(), > which AFAICT is a real system call on most platforms. That might not be > a tremendous amount of overhead, but it's not zero, either. I'm >

Re: common signal handler protection

2023-12-18 Thread Nathan Bossart
rebased for cfbot -- Nathan Bossart Amazon Web Services: https://aws.amazon.com >From c5fc2186960c483d53789f27fcf84771e98c5ca3 Mon Sep 17 00:00:00 2001 From: Nathan Bossart Date: Tue, 28 Nov 2023 14:58:20 -0600 Subject: [PATCH v5 1/3] Check that MyProcPid == getpid() in all signal handlers.

Re: common signal handler protection

2023-11-28 Thread Nathan Bossart
On Tue, Nov 28, 2023 at 06:37:50PM -0800, Andres Freund wrote: > For a moment I was, wrongly, worried this would break signal handlers we > intentionally inherit from postmaster. It's fine though, because we block > signals in fork_process() until somewhere in InitPostmasterChild(), after > we've

Re: common signal handler protection

2023-11-28 Thread Andres Freund
Hi, On 2023-11-27 16:16:25 -0600, Nathan Bossart wrote: > On Wed, Nov 22, 2023 at 02:59:45PM -0800, Andres Freund wrote: > > Hm. I wonder if this indicates an issue. Do the preceding changes perhaps > > make it more likely that a child process of the startup process could hang > > around for

Re: common signal handler protection

2023-11-28 Thread Andres Freund
Hi, On 2023-11-28 15:39:55 -0600, Nathan Bossart wrote: > From e4bea5353c2685457545b67396095e9b96156982 Mon Sep 17 00:00:00 2001 > From: Nathan Bossart > Date: Tue, 28 Nov 2023 14:58:20 -0600 > Subject: [PATCH v3 1/3] Check that MyProcPid == getpid() in all signal > handlers. > > In commit

Re: common signal handler protection

2023-11-28 Thread Nathan Bossart
Here is a new patch set with feedback addressed. -- Nathan Bossart Amazon Web Services: https://aws.amazon.com >From e4bea5353c2685457545b67396095e9b96156982 Mon Sep 17 00:00:00 2001 From: Nathan Bossart Date: Tue, 28 Nov 2023 14:58:20 -0600 Subject: [PATCH v3 1/3] Check that MyProcPid ==

Re: common signal handler protection

2023-11-27 Thread Nathan Bossart
Thanks for taking a look. On Wed, Nov 22, 2023 at 02:59:45PM -0800, Andres Freund wrote: > On 2023-11-22 15:59:44 -0600, Nathan Bossart wrote: >> +/* >> + * Except when called with SIG_IGN or SIG_DFL, pqsignal() sets up this >> function >> + * as the handler for all signals. This wrapper

Re: common signal handler protection

2023-11-22 Thread Andres Freund
Hi, On 2023-11-22 15:59:44 -0600, Nathan Bossart wrote: > Subject: [PATCH v2 1/3] Check that MyProcPid == getpid() in all signal > handlers. > > In commit 97550c0711, we added a similar check to the SIGTERM > handler for the startup process. This commit adds this check to > all signal handlers

Re: common signal handler protection

2023-11-22 Thread Nathan Bossart
On Tue, Nov 21, 2023 at 04:40:06PM -0600, Nathan Bossart wrote: > cfbot seems unhappy with this on Windows. IIUC we need to use > PG_SIGNAL_COUNT there instead, but I'd like to find a way to have just one > macro for all platforms. Here's an attempt at fixing the Windows build. -- Nathan

Re: common signal handler protection

2023-11-21 Thread Nathan Bossart
On Tue, Nov 21, 2023 at 03:20:08PM -0600, Nathan Bossart wrote: > +#ifdef NSIG > +#define PG_NSIG (NSIG) > +#else > +#define PG_NSIG (64) /* XXX: wild guess */ > +#endif > + Assert(signo < PG_NSIG); cfbot seems unhappy with this on Windows. IIUC we need to use

common signal handler protection

2023-11-21 Thread Nathan Bossart
In commit 97550c0, I added a "MyProcPid == getpid()" check in the SIGTERM handler for the startup process. This ensures that processes forked by system(3) (i.e., for restore_command) that have yet to install their own signal handlers do not call proc_exit() upon receiving SIGTERM. Without this