Deadlock when calling printf or malloc from a signal handler
The memory allocation library calls (such as, malloc
) that are provided by the memory debugging library are not async-signal-safe, unlike the implementations in recent versions of the GNU C library.
POSIX does not require
malloc
to be async-signal-safe but some programs might expect this behavior.
For example, a program that calls
printf
from a signal handler can deadlock when memory debugging is enabled in Linaro DDT, because the C library implementation of printf
might call malloc
.
Solution
See a table of the functions that can be safely called from an asynchronous signal handler, in the OpenGroup reference to Signal Concepts