This works, separate file /tmp/test.pl:
use Safe;
my($compartment) = new Safe;
$compartment->permit(qw(:browse));
$compartment->reval("print \"gnu\n\";");
if($@)
{
die $@;
}
print "\n\n";
(Script prints "gnu")
This does not work, in perl-handler Handler.pm:
[...]
use Safe;
sub handler
{
my $r = shift;
return DECLINED unless $r->content_type() eq 'text/html';
[...]
print "Content-type: text/plain\n\n";
my($compartment) = new Safe;
$compartment->permit(qw(:browse));
$compartment->reval("print \"gnu\n\";");
if($@)
{
die $@;
}
[...]
Request results in segfault:
[Thu Jul 24 12:59:56 2003] [notice] child pid 3003 exit signal
Segmentation fault (11)
If I comment out $compartment->reval(), then the process does not
segfault.
Since Safe works outside mod_perl, I'm guessing there's something with the
mod_perl environment that messes things up.
I have run the rest of the setup for several months now without noticing
any other ill effects, so I don't think it is a bad installation of
something. Setup is:
Gentoo linux
perl 5.8.0
apache 1.3.27
mod_perl 1.27
Ideas anyone?
// Joel