Re: Async-unsafe functions in signal handlers - Mailing list pgsql-hackers

From Denis Smirnov
Subject Re: Async-unsafe functions in signal handlers
Date
Msg-id 86F918AA-AE0E-4EAB-B6C1-7000043EAB50@arenadata.io
Whole thread Raw
In response to Re: Async-unsafe functions in signal handlers  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Async-unsafe functions in signal handlers  (Andres Freund <andres@anarazel.de>)
List pgsql-hackers
> 26 авг. 2021 г., в 23:39, Tom Lane <tgl@sss.pgh.pa.us> написал(а):
>
> (BTW, I think it's pretty silly to imagine that adding backtrace()
> calls inside ereport is making things any more dangerous.  ereport
> has pretty much always carried a likelihood of calling malloc(),
> for example.)

I have taken a look through the signal handlers and found out that many of them use malloc() via ereport() and elog().
Hereis the list: 

SIGUSR1
- procsignal_sigusr1_handler(): autoprewarm, autovacuum, bgworker, bgwriter, checkpointer, pgarch, startup, walwriter,
walreciever,walsender 
- sigusr1_handler(): postmaster

SIGFPE:
- FloatExceptionHandler(): autovacuum, bgworker, postgres, plperl

SIGHUP:
- SIGHUP_handler(): postmaster

SIGCHLD:
- reaper(): postmaster

SIGQUIT:
- quickdie(): postgres

SIGTERM:
- bgworker_die(): bgworker

SIGALRM:
- handle_sig_alarm(): autovacuum, bgworker, postmaster, startup, walsender, postgres

I suspect there are lots of potential ways to lock on malloc() inside any of this handlers. An interesting question is
whythere are still no evidence of such locks? 

Best regards,
Denis Smirnov | Developer
sd@arenadata.io
Arenadata | Godovikova 9-17, Moscow 129085 Russia




pgsql-hackers by date:

Previous
From: Peter Geoghegan
Date:
Subject: Re: log_autovacuum in Postgres 14 -- ordering issue
Next
From: Andres Freund
Date:
Subject: Re: Async-unsafe functions in signal handlers