[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: sqlite memory allocation and async signal safety
From: |
Eli Zaretskii |
Subject: |
Re: sqlite memory allocation and async signal safety |
Date: |
Thu, 24 Mar 2022 13:08:50 +0200 |
> From: Po Lu <luangruo@yahoo.com>
> Cc: emacs-devel@gnu.org
> Date: Thu, 24 Mar 2022 18:21:29 +0800
>
> Eli Zaretskii <eliz@gnu.org> writes:
>
> > I think we used to block input around function calls that could
> > allocate memory because our signal handlers, and in particular SIGIO
> > handler, did non-trivial stuff. Nowadays our signal handlers just set
> > a flag and return, so I'm not sure this is needed anymore. Especially
> > when system library malloc is called, which AFAIU is mostly async-safe
> > nowadays on modern platforms.
> >
> > Am I missing something?
>
> Unfortunately, most system malloc implementations are still not
> async-signal safe, but if all that happens is a flag being set, then I
> don't think calling block_input is required anymore.
>
> Which flag is that, and where is it tested?
It depends on the signal. Look at the signal handlers we install.
For SIGIO, this is the handler:
void
handle_input_available_signal (int sig)
{
pending_signals = true;
if (input_available_clear_time)
*input_available_clear_time = make_timespec (0, 0);
}
and the flag is pending_signals.