Joel Palmius wrote:
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, I have reproduced the segfault using your test script.


It's handy to have p5p people sitting next to you. Just asked this question Tim Bunce, and he replied:

  "Safe is a failed experiment. It works only for several cases. TIEHANDLE is
  not one of them [print under mod_perl uses a tied STDOUT]. Do not use it if
  it doesn't work for you."

I'm supposed to ask Dan Sugalsky whether perl6 will have this functionality designed from the ground up.

We could prevent the segfault in mod_perl, but you still won't be able to use Safe under it. So IMHO it's not worth the slowdown to do extra checks.

Should probably add it to the troubleshooting section.

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com



Reply via email to