Why can't malloc be used in signal handlers? What can "happen wrong"?
相关问题
- Why should we check WIFEXITED after wait in order
- UNIX Bash - Removing double quotes from specific s
- bash delete line condition
- Trying to make a permanent Alias - UNIX
- Generating signed XPI via jpm failed
A signal handler can be called at any time, including during times when another call to
malloc
is in progress. If this happens, one of two things will occur:malloc
will be unable to acquire the heap lock.malloc
does acquire the lock (or doesn't think it needs it), then proceeds to render the heap inconsistent, leading to a later crash.