Subject: | Test::MockObject causes Apache2 child process segmentation fault even when no Test::MockObject functions are called. |
This problem shows up when an Apache2 mod_perl2 response handler tries
to run a shell command, which creates a new process. The handler (and
shell command) works fine for several HTTP requests, and then it fails
with the following message in the Apache2 error log:
[Tue Jan 03 21:48:52 2012] [notice] child pid 19898 exit signal
Segmentation fault (11)
This is repeatable, and happens even if none of the Test::MockObject
functions are called. The problem goes away when "use
Test::MockObject;" is commented out or removed. Here is a trivial
Apache2 mod_perl2 response handler (between the double brackets) that
demonstrates the problem:
[[
#! /usr/bin/perl -w
package MyApache2::Chain;
use strict;
use Apache2::Const -compile => qw(:common);
use Apache2::SubRequest (); # for $r->internal_redirect
### Comment out the following line and the Apache2 child
### segmentation fault no longer occurs:
use Test::MockObject;
sub handler
{
my $r = shift || die;
my $f = $ENV{DOCUMENT_ROOT} . "/date.txt";
system("date >> $f 2> /dev/null");
$r->internal_redirect("/date.txt");
return Apache2::Const::OK;
}
##### DO NOT DELETE THE FOLLOWING LINE! #####
1;
]]
I am using Apache 2.2.14-5ubuntu8.7 with the worker MPM, perl 5.10.1 and
libapache2-mod-perl2 2.0.4-6ubuntu1 under Ubuntu 10.04. The problem
occurs with both the Apache2 worker MPM and the Apache2 prefork MPM.