Calling malloc from a signal handler

Jason Evans jasone at FreeBSD.org
Fri Sep 19 14:11:07 UTC 2008


Stephen Montgomery-Smith wrote:
> I notice that if you use "malloc" from within a signal handler on 
> FreeBSD-6.x, that you can potentially trigger a "recursive call" error.
> 
> But this seems to have changed in FreeBSD-7.x.

The malloc implementation is completely new in FreeBSD 7, so not all of 
the internal error checking code is the same.

> Is it now permissible to call "malloc" from within a signal handler in 
> FreeBSD-7.x?

Calling malloc from within a signal handler can cause application 
deadlock, so although you won't see an error message printed, you are 
unlikely to be happy with the results.

Jason


More information about the freebsd-hackers mailing list