Hi Perrin

Thanks all for your responses. I'd like to try your suggestion, but cannot find documentation on "apache error page handlers". Presumably that's code that Apache runs if an httpd dies. mod_perl: HTTP <http://perl.apache.org/docs/2.0/user/handlers/http.html>/Handlers <http://perl.apache.org/docs/2.0/user/handlers/http.html> describes mod_perl's complete HTTP Request processing, but doesn't handle fatal Perl errors./ Perhaps you're referring to Apache's ErrorDocument <http://httpd.apache.org/docs/2.0/mod/core.html#errordocument> (also described in Custom Error Response <http://httpd.apache.org/docs/2.0/custom-error.html>). While that can run local Perl (in a new process of course) as in the example
|       | ErrorDocument 500 /cgi-bin/crash-recover.pl||
it isn't clear to me how to access $r (which I assume means the Request).
However, I could write a little info to a file which that crash-recover.pl reads. It will only run occasionally.
And given your observation
Also, be careful with using a universal DIE handler, since it kills
exception handling in code that uses eval {} blocks.
it might be better to not assign a special handler to $SIG{__DIE__} but rather to just handle stuff in crash-recover.pl. Alternatively, I could write a handler that did

$original_handler = $SIG{__DIE__};

sub myHandler {
if( out_of_memory ) {
  # increase RLIMIT_AS a little so memory can be allocated
# write some info (especially user identity) to a file, that crash-recover.pl will use
} else {
 $original_handler( @_ );
}
}

BR
A


Perrin Harkins wrote:
On Thu, Mar 11, 2010 at 4:41 PM, ARTHUR GOLDBERG <a...@cs.nyu.edu> wrote:
2) Kill apache httpd processes occasionally, to control the effect of slow
perl memory leaks. I'll do this by setting MPM Worker MaxRequestsPerChild to
some modest value. (I'll try 100.)

You definitely should be doing that, and possibly running
Apache2::SizeLimit as well.  There's plenty of documentation about
this on the site.

OK, that kills big processes. What happens next is that Perl runs out of
memory (outputs "Out of Memory!") and calls the __DIE__ signal handler. So,
my plan is to catch the signal, redirect the browser to an error page, and
finally kill the process.

A simpler solution would be to set something in $r->notes from your
DIE handler and use that in an apache error page handler to determine
what to show.

Also, be careful with using a universal DIE handler, since it kills
exception handling in code that uses eval {} blocks.

How
does one determine whether -DPERL_EMERGENCY_SBRK is defined, and if one does
that does STDOUT still work?

It's really not much different from what you're already doing, but you
can check your compile options with perl -V.

- Perrin


--
Arthur P. Goldberg, PhD

Research Scientist in Bioinformatics
Plant Systems Biology Laboratory
www.virtualplant.org

Visiting Academic
Computer Science Department
Courant Institute of Mathematical Sciences www.cs.nyu.edu/artg

a...@cs.nyu.edu
New York University
100 Washington Sq East
8th Floor Silver Building


Reply via email to