Joel Palmius wrote:
use Safe;
my($compartment) = new Safe; $compartment->permit(qw(:browse)); $compartment->reval("print \"gnu\n\";");
[...]
Request results in segfault:
[Thu Jul 24 12:59:56 2003] [notice] child pid 3003 exit signal Segmentation fault (11)
[...]
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.
And here is the patch that prevents the segfault. I'm not sure whether it should go in. I have attached it as well, since the original had \t in it and it'll be certainly mangled.
Index: src/modules/perl/Apache.xs =================================================================== RCS file: /home/cvs/modperl/src/modules/perl/Apache.xs,v retrieving revision 1.128 diff -u -r1.128 Apache.xs --- src/modules/perl/Apache.xs 6 Jul 2003 04:51:20 -0000 1.128 +++ src/modules/perl/Apache.xs 24 Jul 2003 14:38:33 -0000 @@ -1134,7 +1134,9 @@ sv_setiv(sendh, 0); } else { - CV *cv = GvCV(gv_fetchpv("Apache::write_client", FALSE, SVt_PVCV)); + /* should exist already */ + CV *cv = GvCV(gv_fetchpv("Apache::write_client", GV_ADDWARN, SVt_PVCV)); + if(!cv) croak("can't find Apache::write_client, are you using Safe.pm?"); soft_timeout("mod_perl: Apache->print", r); PUSHMARK(mark); #ifdef PERL_OBJECT
__________________________________________________________________ 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
Index: src/modules/perl/Apache.xs =================================================================== RCS file: /home/cvs/modperl/src/modules/perl/Apache.xs,v retrieving revision 1.128 diff -u -r1.128 Apache.xs --- src/modules/perl/Apache.xs 6 Jul 2003 04:51:20 -0000 1.128 +++ src/modules/perl/Apache.xs 24 Jul 2003 14:45:16 -0000 @@ -1134,7 +1134,9 @@ sv_setiv(sendh, 0); } else { - CV *cv = GvCV(gv_fetchpv("Apache::write_client", FALSE, SVt_PVCV)); + /* should exist already */ + CV *cv = GvCV(gv_fetchpv("Apache::write_client", GV_ADDWARN, SVt_PVCV)); + if(!cv) croak("can't find Apache::write_client, are you using Safe.pm?"); soft_timeout("mod_perl: Apache->print", r); PUSHMARK(mark); #ifdef PERL_OBJECT