Subject: | Sys HostIP flawed by mod_perl bug |
There is a bug in the 1.99 series of mod_perl that flaws apache if you
use Sys::HostIP on Linux / Mac. This is caused by a call to "local %ENV"
in HostIP.pm. It got fixed at some point and should be ok in the latest
mod_perl 2+...
If you are using mod_perl 1.99* on *NIX with Sys::HostIP 1.3.1 beware...
See:
http://www.google.co.uk/search?q=site:apache.org+%22local+env%22+walsham&num=100&hl=en&lr=&filter=0
====================================================================
Hi Jonathan,
Thank you for the very useful Sys::HostIP.
I thought you might be interested to know there is a problem in the
latest mod_perl versions that causes a problem for Sys::HostIP. The bug
details I posted to modperl@perl.apache.org are below.
Within the environments I am running, commenting out local %ENV in
_get_unix_interface_info is enough to get things working ok, although I
realise this might not be ok for everyone.
Best Wishes
Peter Walsham
Summary
============
Calling "local %ENV" from anywhere inside a mod_perl handler will
terminally flaw the httpd process. The httpd process will function fine
on the first request, but will die the next time it is asked to handle a
request.
Apache error.log or error_log will contain one of the following.
[notice] child pid <PID> exit signal Segmentation fault (11)
[notice] child pid <PID> exit signal Bus error (10)
Calling local %ENV seems fine on:
mod_perl 1.99_09
Calling local %ENV creates a terminal flaw on:
mod_perl 1.99_16
mod_perl 1.999_21
mod_perl 2.0.2
I spotted this because I was using Sys::HostIP, which has been calling
local %ENV inside _get_unix_interface_info since version 1.1 (07 Apr
2002).
http://search.cpan.org/src/BLUELINES/Sys-HostIP-1.1/HostIP.pm
http://search.cpan.org/src/BLUELINES/Sys-HostIP-1.3.1/HostIP.pm
Some example test files are given below.
Testing Performed On
=========================
Main tests on:
Fedora Core 3
Mac OS X 10.3.9
Results were consistent with other installs on:
Red Hat 9
Fedora Core 2 (FC2)
Fedora Core 4 (FC4)
Red Hat Enterprise Linux 3 (RHEL3)
Mac OS X 10.4.3
Windows Server 2000
Windows Server 2003
Windows XP Pro
Configuring httpd.conf
===========================
For ease of testing reduce the number of forked httpd processes in
httpd.conf:
<IfModule prefork.c>
StartServers 1
MinSpareServers 1
MaxSpareServers 1
MaxClients 150
MaxRequestsPerChild 0
</IfModule>
Fedora Core 3
==================
First tried with the RPMs FC3 came with:
httpd-2.0.52-3.i386.rpm
mod_perl-1.99_16-3.rpm
Then upgraded to latest mod_perl and Apache to see if the problem had
been fixed (which it hadn't).
mod_perl 2.0.2 (VERSION 2.000002)
Apache 2.0.53
Perl 5.8.5
The process dies with:
[notice] child pid <PID> exit signal Segmentation fault (11)
FILE: Mod_Perl_ENV_Bug_Test.conf
LoadModule perl_module modules/mod_perl.so
Listen 80
<VirtualHost *:80>
PerlOptions +Parent
PerlSwitches -Mlib=/home/myhome/Mod_Perl_ENV_Bug_Test
PerlModule Bundle::Apache2
PerlModule MyHandler
<LocationMatch ^/+$>
SetHandler perl-script
PerlResponseHandler MyHandler
</LocationMatch>
</VirtualHost>
FILE: /home/myhome/Mod_Perl_ENV_Bug_Test/MyHandler.pm
package MyHandler;
use strict;
use warnings;
use Apache2::RequestRec ();
use Apache2::Const ('-compile',('OK'));
use Sys::HostIP;
sub handler($) {
my $r = shift();
# The error is produced by either of the following two lines
local %ENV;
#Sys::HostIP->ips();
$r->content_type('text/html');
print('Testing');
return Apache2::Const::OK;
}
1;
Mac OS X 10.3.9
====================
mod_perl was compiled from source.
Darwin Kernel Version 7.9.0
mod_perl 2.0.0-RC4 (VERSION 1.999021)
Apache 2.0.52
Perl 5.8.1-RC3
The process dies with:
[notice] child pid <PID> exit signal Bus error (10)
FILE: Mod_Perl_ENV_Bug_Test.conf
LoadModule perl_module modules/mod_perl.so
Listen 80
<VirtualHost *:80>
PerlOptions +Parent
PerlSwitches -Mlib=/home/myhome/Mod_Perl_ENV_Bug_Test
PerlModule Apache2
PerlModule MyHandler
<LocationMatch ^/+$>
SetHandler perl-script
PerlResponseHandler MyHandler
</LocationMatch>
</VirtualHost>
FILE: /home/myhome/Mod_Perl_ENV_Bug_Test/MyHandler.pm
package MyHandler;
use strict;
use warnings;
use Apache::RequestRec ();
use Apache::Const -compile=>qw(OK);
use Sys::HostIP;
sub handler($) {
my $r = shift();
# The error is produced by either of the following two lines
local %ENV;
#Sys::HostIP->ips();
$r->content_type('text/html');
print('Testing');
return Apache::OK;
}
1;
-- Axomic Ltd 338 City Road London EC1V 2PY t: +44 (0)20 7239 8287 m:
+44 (0)7812 122418 http://www.axomic.com