[asterisk-dev] SIGHUP handling
Russell Bryant
russell at digium.com
Mon Jan 29 16:11:21 MST 2007
We have various bug reports that show crashes within malloc/calloc, so I
started thinking about possible things that could happen to corrupt the
internals of malloc.
One thing is the use of memory allocation functions within a signal
handler. I did an audit of the signal handlers in asterisk.c and there
is one that does something very bad.
static void hup_handler(int num)
{
if (option_verbose > 1)
printf("Received HUP signal -- Reloading configs\n");
if (restartnow)
execvp(_argv[0], _argv);
/* XXX This could deadlock XXX */
ast_module_reload(NULL);
signal(num, hup_handler);
}
One way SIGHUP is used is to trigger a restart of all of Asterisk if
Asterisk is running with the -c option. That's fine, because it will
never go past execvp(). However, should SIGHUP be received for some
other reason, calling ast_module_reload() is very bad if it interrupts a
call to malloc/calloc/etc., or some other non-reentrant function that
will then be called again during the reload process.
So, can anyone think of a good reason why this hander calls
ast_module_reload()?
--
Russell Bryant
Software Engineer
Digium, Inc.
More information about the asterisk-dev
mailing list