Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed bug RT#47929 which caused the XS Stash to die mysteriously

when calling code that used string evaluation (e.g. DateTime).
  • Loading branch information...
commit cb1d793924ac105c188c2a573b7233621a6c5e24 1 parent f04f2dc
@abw authored
View
3  Changes
@@ -14,6 +14,9 @@
# Version 2.23 - not released yet
#------------------------------------------------------------------------
+* Fixed bug RT#47929 which caused the XS Stash to die mysteriously when
+ calling code that used string evaluation (e.g. DateTime).
+
* Added the TRACE_VARS option to keep track of what variables are used
in a template. It's not documented yet. See t/trace_vars.t for an
example of use.
View
2  lib/Template/Stash/XS.pm
@@ -127,7 +127,7 @@ Doug Steinwand E<lt>dsteinwand@citysearch.comE<gt>
=head1 COPYRIGHT
-Copyright (C) 1996-2009 Andy Wardley. All Rights Reserved.
+Copyright (C) 1996-2012 Andy Wardley. All Rights Reserved.
This module is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
View
27 t/stash-xs.t
@@ -29,6 +29,7 @@ if ($@) {
skip_all('cannot load Template::Stash::XS');
}
+
#------------------------------------------------------------------------
# define some simple objects for testing
#------------------------------------------------------------------------
@@ -106,6 +107,11 @@ my $data = {
},
correct => sub { die @_ },
buggy => Buggy->new(),
+ str_eval_die => sub {
+ # This is to test bug RT#47929
+ eval "use No::Such::Module::Exists";
+ return "str_eval_die returned";
+ },
};
my $stash = Template::Stash::XS->new($data);
@@ -118,6 +124,7 @@ match( $stash->get('baz.boz'), 30 );
match( $stash->get('baz.boz'), 40 );
match( $stash->get('baz.biz'), '<undef>' );
match( $stash->get('baz(50).biz'), '<undef>' ); # args are ignored
+#match( $stash->get('str_eval_die'), '' );
$stash->set( 'bar.buz' => 100 );
match( $stash->get('bar.buz'), 100 );
@@ -403,3 +410,23 @@ foo is { "" = "full" "one" = "baz" }
[% cmp_ol.hello %]
-- expect --
Hello
+
+-- test --
+Before
+[% TRY;
+ str_eval_die;
+ CATCH;
+ "caught error: $error";
+ END;
+%]
+After
+-- expect --
+Before
+str_eval_die returned
+After
+
+-- test --
+[% str_eval_die %]
+-- expect --
+str_eval_die returned
+
View
2  t/stop.t
@@ -17,7 +17,7 @@
#========================================================================
use strict;
-use lib qw( ./lib ../lib );
+use lib qw( ./lib ../lib ../blib/lib ../blib/arch ./blib/lib ./blib/arch );
use vars qw( $DEBUG );
use Template::Test;
use Template::Parser;
View
8 xs/Stash.xs
@@ -14,7 +14,7 @@
* Doug Steinwand <dsteinwand@citysearch.com>
*
* COPYRIGHT
-* Copyright (C) 1996-2009 Andy Wardley. All Rights Reserved.
+* Copyright (C) 1996-2012 Andy Wardley. All Rights Reserved.
* Copyright (C) 1998-2000 Canon Research Centre Europe Ltd.
*
* This module is free software; you can redistribute it and/or
@@ -638,9 +638,13 @@ static SV *call_coderef(pTHX_ SV *code, AV *args) {
if ((svp = av_fetch(args, i, FALSE)))
XPUSHs(*svp);
PUTBACK;
- count = call_sv(code, G_ARRAY);
+ count = call_sv(code, G_ARRAY|G_EVAL);
SPAGAIN;
+ if (SvTRUE(ERRSV)) {
+ die_object(aTHX_ ERRSV);
+ }
+
return fold_results(aTHX_ count);
}

2 comments on commit cb1d793

@robinsmidsrod

I've just tested out my broken test case with your patch. My code in https://github.com/robinsmidsrod/datetime-template-bug now works well on these configurations (as noted in the README):

Description:    Ubuntu 10.04.3 LTS
Linux server 2.6.32-36-generic-pae #79-Ubuntu SMP Tue Nov 8 23:25:26 UTC
2011 i686 GNU/Linux
This is perl 5, version 12, subversion 2 (v5.12.2) built for i686-linux
POSIX version: 1.19
DateTime version: 0.66
Template version: 2.22_1 (commit bb1080b)
Template stash used: Template::Stash::XS
Description:    Ubuntu 10.04.3 LTS
Linux server 2.6.32-36-generic-pae #79-Ubuntu SMP Tue Nov 8 23:25:26 UTC
2011 i686 GNU/Linux
This is perl 5, version 14, subversion 0 (v5.14.0) built for i686-linux
POSIX version: 1.24
DateTime version: 0.72
Template version: 2.22_1 (commit bb1080b)
Template stash used: Template::Stash::XS
@robinsmidsrod

Thanks a bunch for finally solving this issue. Much obliged!

Please sign in to comment.
Something went wrong with that request. Please try again.