Re: [AD] double signal hang fix |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
On 2003-06-23, Vincent <Vincent.Penquerch@xxxxxxxxxx> wrote:
> > I haven't looked at it properly, but I think it's the wrong way to fix
> > it. It should be possible to stop signals from arriving
> > while we're in
> > the middle of a signal handler, using sigaction() to install
> > the handler
>
> Ah, I wasn't aware of that difference.
>
> > instead of signal(). I'd also prefer to know why two signals
> > are being
> > raised in the first place.
>
> In my case, I got a SIGSEGV, the handler is called, then calls
> allegro_exit, which raises a SIGSEGV as well (memory corruption).
I see. To protect against this, I think the signal handler should not
trust allegro_exit() to do what it is supposed to. The old signal
handlers (i.e. the ones that were present when allegro_init() was
called) should be restored by the signal handler itself, before it calls
allegro_exit().
PS. I don't know why signals are arriving during the execution of the
signal handler. The man page says that the raised signal is blocked for
the duration, and I confirmed it on a small test case. I also tried
blocking _all_ signals during the signal handler, by installing the
handler with `sigaction'. But a second signal still arrives while the
first signal is being handled.
PPS. A test case for this is to simply make allegro_exit() segfault
somewhere, e.g. in a _add_exit_func() callback. No need to hack the
Allegro source, as I was doing :-)
--
王浩禎