Subject: | TZ::Local crashes if called from inside Template toolkit XS stash |
The attached file calls DateTime::TimeZone::Local->TimeZone() from
inside a callback function in a template toolkit xs stash.
This has the surprising result of neatly exiting Perl upon return from
the callback function, rather than returning to the template processing.
This was tested with Template Toolkit 2.20 and 2.21, and
DateTime::TimeZone 0.91 on Perl 5.10.0 on Linux and MacOSX.
It seems to work OK with Perl 5.8.8 and DT::TZ 0.70.
Subject: | crash.pl |
#!/usr/bin/perl
use strict;
use warnings;
use DateTime::TimeZone::Local;
use Template;
use Template::Stash::XS;
print "DateTime::TimeZone version: " . $DateTime::TimeZone::VERSION . "\n";
print "Template version: " . $Template::VERSION . "\n";
my $status = 'FAILED';
my $template = '[% crasher() %]';
my $output;
# Note that only the XS stash fails..
my $tt2 = Template->new( STASH => Template::Stash::XS->new );
$tt2->process(\$template, { crasher => \&crasher }, \$output);
print "Generated output: $output\n";
$status = 'SUCCESS';
sub crasher {
DateTime::TimeZone::Local->TimeZone;
warn "** In crasher(), about to return..";
return 'foo';
}
sub END { print "Status: $status\n"; }