If something goes really wrong with your code, Perl may die with an "Out of memory!" and/or "Callback called exit" message. Common causes of this are infinite loops, deep recursion, or calling an undefined subroutine.
If -DPERL_EMERGENCY_SBRK is defined, running out of memory need not be a fatal error: a memory pool can be allocated by using the special variable $^M. See the perlvar manpage for more details.
If you compile with that option and add use Apache::Debug level => 4; to your Perl code, it will allocate the $^M emergency pool and the $SIG{_ _DIE_ _} handler will call Carp::confess( ), giving you a stack trace that should reveal where the problem is. See the Apache::Resource module for the prevention of spinning httpds.
Note that Perl 5.005 and later have PERL_EMERGENCY_SBRK turned on by default.
Another trick is to have a startup script initialize Carp::confess( ), like this:
use Carp ( );
eval { Carp::confess("init") };
This way, when the real problem happens, Carp::confess doesn't eat memory in the emergency pool ($^M).
 
Continue to: