Subject: | Bug found and fixed |
Date: | Mon, 3 May 2010 14:11:28 -0700 |
To: | bug-CGI.pm [...] rt.cpan.org |
From: | Jeremy Goodridge <jgoodridge [...] gmail.com> |
I have found a problem in CGI.pm in which CGI params do not get refreshed on
subsequent requests. This didn't happen with every request, but I found
that after about 5 minutes or 30 requests or so, suddenly, CGI would start
using the same parameters for every request. The problem occurred on
mod_perl 1.31 but NOT on mod_perl 1.29. I don't know about mod_perl 1.30.
To fix I changed line 360:
from:
$r->register_cleanup(\&CGI::_reset_globals);
to:
$r->push_handlers( 'PerlCleanupHandler', \&CGI::_reset_globals);
I thought the two snippets of code were identical but apparently not. So,
this may really expose a mod_perl problem, or perhaps register_cleanup is
now deprecated. Note that adding the cleanup handler explicitly in the
httpd conf also works. So, specifically, adding PerlCleanupHandler
CGI::_reset_globals to one's httpd conf fixes the problem.
I believe this problem is related to the following conversation I found:
http://www.mail-archive.com/modperl@apache.org/msg21862.html
This conversation mentioned an incompatibility between Apache::SizeLimit and
CGI.pm. I AM using Apache::SizeLimit and so that might be what exposes the
problem. That might be why it takes some time to occur -- perhaps once
Apache SizeLimit is engaged, CGI's cleanup handler is destroyed. I don't
know. Or perhaps it is something fundamental within mod_perl.
My installation includes:
Apache: 1.3.41
mod_perl: 1.31
CGI.pm: 3.49
Apache::SizeLimit 0.91-dev
Redhat EL5.
As a further note, I noticed the following in the SizeLimit.pm source code:
# This used to use $r->post_connection but there's no good way
to
# test it, since apparently it does not push a handler onto
the
# PerlCleanupHandler phase. That means that there's no way to
use
# $r->get_handlers() to check the results of calling this
method.
$r->push_handlers( 'PerlCleanupHandler',
sub { $class->_exit_if_too_big(shift) } );
So, that suggests to me that post_connection (which is supposed to be
identical to register_cleanup) doesn't quite do what is expected. And
reinforces the need for my fix.
Please let me know if you have questions or need more information about my
setup.
Jeremy Goodridge