Hi,

I believe I have a reproducible bug with HTML::Embperl 1.2.0.  On the
support pages this list was mentioned as the correct place to address such
concerns.

The problem occurs when I call HTML::Embperl::Execute with an
"inputfile" parameter and a "package" parameter.  The package consists of
an instance of a Safe->root() that has data varglobbed in.

Essentially, what happens is that some meta-commands in Embperl seem to
cache data somewhere, so subsequent calls to the Execute routine (as is
common in a mod_perl scenario) reuse data incorrectly.  In particular,
this bug is manifest in the [$ foreach $] command. 

It's difficult to describe, so I'm enclosing a .tgz of a script that will
reproduce the error, but here is a snippet of the code:

sub printTemplate 
{
   my ($filename, $dataRef) = @_;

   my $compartment = new Safe();

   foreach (keys %{$dataRef}) {
      $ {$compartment->varglob($_)} = $dataRef->{$_};
   }

   my $root = $compartment->root();

   HTML::Embperl::Execute({ 'inputfile' => $filename, 'package' => $root});   
}


In the attached example, I call this routine twice with the same data and
the same filename, and it produces quite different results.  Important to
note is that the data itself is not modified between the calls.  I have
more or less isolated it to the [$ foreach $] command, as it seems to
effect arrays, and simple join()s on those arrays are handled correctly.  

This all sounds more complicated than it really is -- the example will do
a better job explaining it than I can.

Right now, we work around the problem by reading in the file first,
passing the text as the 'input' to Execute, and creating a unique value
for 'inputfile' on each call.  This seems to force Embperl to recompile
and avoids the bug.  Unfortunately, it obviously causes some performance
loss, too.

I've been poking around epcmd.c for a while, and may really dig in and see
if I can fix it, but I figured it couldn't hurt to post and see if anyone
else has encountered this or has a patch or workaround.  And for the
curious, we are using Embperl, mod_perl, and Linux extensively on our
front-end machines at www.eziba.com.  

Thanks,

-DeWitt











embperl_bug_repro.tgz

Reply via email to