[ic] perl5.6.1 and evals SOLVED now UNSOLVED again

Ed LaFrance interchange-users@lists.akopia.com
Mon Jun 18 12:27:00 2001


At 06:07 PM 06/15/2001 -0400, you wrote:

>I've got a small usertag and page that seems
>to kill perl evals.  This is in interchange
>4.7.3 on our debian machines. It does not seem
>to kill interchange itself, so I'm not 100%
>sure if it is a perl issue.  It is, however,
>dependant on the perl version, so maybe it
>is.  Anyone upgrading 5.6.0 to 5.6.1, at least
>on a debian box, should be cautious.
>
>
>--
>
>Description:
>
>On an up to date debian "unstable" system running
>perl 5.6.1 this usertag and simple eval causes evals
>to misbehave (segfault?) within an unpatched interchange.
>
>The same thing happens with a home build perl 5.7.1
>(using & -d defaults)  100% tests successful.
>
>That same interchange runs on 5.6.0 machines no problem.
>
>If I hack it to run with a local 5.6.0 binary and all
>the 5.6.1 libs (modify Config.pm and symlink a few
>5.6.0 directories to 5.6.1 equivalents) it works.
>
>I do not know how to troubleshoot this further.  It's
>not like I can run interchange in gdb.  Nor can I tell
>for sure if this is a perl or interchange issue, except
>that perl is behaving inconsistently from 5.6.0 to 5.6.1.
>
>I'd be curious if anyone else can run this on a perl 5.6.1
>machine and to hear if it works or does not.
>
>
>
>#############
>## xxx
>
>UserTag xxx   HasEndTag 1
>UserTag xxx   Interpolate       0
>UserTag xxx   Routine<<XXX
>sub {
>     ::logGlobal("logGlobal in scope in tag");
>     my $str = eval {
>         my $OUT=eval $_[0];
>         die $@ if $@;
>         return '' unless $OUT;
>         return $OUT;
>     };
>     if($@) {
>         my($err);
>         $err=$@;
>         ::logGlobal("EVAL FAILED: $err");
>         $err=~s/\n/<BR>/g;
>         ::logGlobal("xxx done");
>         return "error: $err";
>     }
>     ::logGlobal("xxx done");
>     return "str: $str";
>}
>XXX
>
>#end
>
>For this simplified page:
>
><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
>[xxx] { use strict 'vars'; my(@OUT); # COMMENT THIS LINE AND EVAL FAILS 
>AND IS **NOT** TRAPPED push @OUT,'HELLO WORLD'; ::logGlobal("logGlobal is 
>in scope here"); return join '',@OUT; } [/xxx]
>
>The development machine logs this and returns server read error (probably 
>segfault)
>genii.znet.maine.com Rkagu3AP:maine.com - [15/June/2001:12:02:49 -0500] 
>PAGE: xxx lobsters /Catalog/lobsters.cgi/xxx.html logGlobal in scope in tag
>
>
>The production machine (5.6.0) logs this and returns page with "str:"
>genii.znet.maine.com gWuyvxkm:maine.com - [15/June/2001:12:04:13 -0500] 
>PAGE: xxx products /Catalog/products.cgi/xxx.html logGlobal in scope in tag
>genii.znet.maine.com gWuyvxkm:maine.com - [15/June/2001:12:04:13 -0500] 
>PAGE: xxx products /Catalog/products.cgi/xxx.html EVAL FAILED: Global 
>symbol "@OUT" requires explicit package name at (eval 45) line 5.
> > Global symbol "@OUT" requires explicit package name at (eval 45) line 7.
> >

Chris, I think your Perl skills are far greater than mine, but I am 
wondering if you have just been benefiting from an undocumented loophole in 
the past. I have written a few UserTags which use external Perl modules, 
any the only place I have had success with 'use' is just inside the tag 
Routine, before the sub {}:

UserTag foo Routine <<EOR
use Somelib;
sub {
...
}
EOR

...otherwise I would get an error message quite similar to the one you posted.

- Ed L.



===============================================================
New Media E.M.S.               Software Solutions for Business
463 Main St., Suite D          eCommerce | Consulting | Hosting
Placerville, CA  95667         edl@newmediaems.com
(530) 622-9421                 http://www.newmediaems.com
(866) 519-4680 Toll-Free       (530) 622-9426 Fax
===============================================================