Jean-Sebastien Guay wrote:

Steve,



and the good news for you is that I've reproduced your problem.



GREAT! Thank you so much for persevering through this! So do you have a traceback or some info that the developers might be able to use to track this down?

Not sure how to get a stack backtrace on Windows. I don't even get the Application Error popup window with a "Debug" button inviting me to have go :-(

However, I have massively simplified the test program that reproduces the problem.

I've moved the template itself in-core rather than processing an external file and removed everything else that I could without the problem going away. I found that almost whatever I removed from the template -- not just the <nobr> tag -- "fixed" it, and I began to wonder about the *size* of the template.

So then I replaced the HTML page content with loads of dots, and sure enough, the problem goes away if you reduce the number of dots sufficiently. It seems that the program breaks if the template size is > 612 bytes, and works if it is <= 612 bytes! (Try changing $size from 613 to 612 in getTemplate() to "fix" it!)

Template-Toolkit's Template::Manual::Config manpage says that Perl will segfault using the INTERPOLATE option with templates > 32 kB due to limitations in Perl's regex engine, and sure enough another way to "fix" the attached program is to change "INTERPOLATE => 1" to "INTERPOLATE => 0".

I don't know where the 612 byte limit comes from, but it's certainly not Perl itself that has such a small limit -- the program runs fine in CGI and mod_perl 1 environments with $size set way higher than 32 kB on my machine.

So a temporary fix would appear to be to not use the INTERPOLATE option if you can manage without it.

I might have to leave it to Randy for a fuller explanation of where the 612 bytes limit is creeping in.

Steve
#!perl

use strict;
use warnings;

use Template;

MAIN: {
    print qq[Content-Type: text/html\n\n];
    processTemplate();
}

sub processTemplate {
    my $template = Template->new({ INTERPOLATE => 1 });
    my $t_text = getTemplate();
    $template->process($t_text)
        or die("Error processing template: " . $template->error());
}

sub getTemplate {
    my $size = 612;

    my $header = '<html><body>';
    my $footer = '</body></html>';
    my $centre = '.' x ($size - length($header) - length($footer));
    my $t_text = $header . $centre . $footer;

    return \$t_text;
}

Reply via email to