r39417 - in /branches/upstream/libautodie-perl/current: AUTHORS Changes MANIFEST META.yml lib/Fatal.pm lib/autodie.pm lib/autodie/exception.pm lib/autodie/exception/system.pm lib/autodie/hints.pm t/string-eval-basic.t t/string-eval-leak.t

jawnsy-guest at users.alioth.debian.org jawnsy-guest at users.alioth.debian.org
Mon Jul 6 17:25:52 UTC 2009


Author: jawnsy-guest
Date: Mon Jul  6 17:25:46 2009
New Revision: 39417

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=39417
Log:
[svn-upgrade] Integrating new upstream version, libautodie-perl (2.06)

Added:
    branches/upstream/libautodie-perl/current/t/string-eval-basic.t   (with props)
    branches/upstream/libautodie-perl/current/t/string-eval-leak.t   (with props)
Modified:
    branches/upstream/libautodie-perl/current/AUTHORS
    branches/upstream/libautodie-perl/current/Changes
    branches/upstream/libautodie-perl/current/MANIFEST
    branches/upstream/libautodie-perl/current/META.yml
    branches/upstream/libautodie-perl/current/lib/Fatal.pm
    branches/upstream/libautodie-perl/current/lib/autodie.pm
    branches/upstream/libautodie-perl/current/lib/autodie/exception.pm
    branches/upstream/libautodie-perl/current/lib/autodie/exception/system.pm
    branches/upstream/libautodie-perl/current/lib/autodie/hints.pm

Modified: branches/upstream/libautodie-perl/current/AUTHORS
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libautodie-perl/current/AUTHORS?rev=39417&op=diff
==============================================================================
--- branches/upstream/libautodie-perl/current/AUTHORS (original)
+++ branches/upstream/libautodie-perl/current/AUTHORS Mon Jul  6 17:25:46 2009
@@ -78,3 +78,13 @@
 
 Toby Corkindale
         - Documentation copyediting and improvements.
+
+Vincent Pit
+        - Additional test cases.
+        - Help in tracking down string eval weirdness.
+        - Code review and sanity support.
+
+Florian Ragwitz
+        - Help in tracking down string eval weirdness.
+        - Letting me cargo-cult code from B::Hooks::EndOfScope.
+

Modified: branches/upstream/libautodie-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libautodie-perl/current/Changes?rev=39417&op=diff
==============================================================================
--- branches/upstream/libautodie-perl/current/Changes (original)
+++ branches/upstream/libautodie-perl/current/Changes Mon Jul  6 17:25:46 2009
@@ -1,4 +1,21 @@
 Revision history for autodie
+
+2.06  Tue Jul  7 00:01:37 AUSEST 2009
+
+        * BUG: Explicitly documented that autodie does NOT play
+          nicely with string evals, especially under Perl 5.10.x.
+          Please avoid using string evals while autodie is in scope.
+
+        * TEST: Check for autodie leaking out of scope in the
+          presence of string evals.  (string-eval-leak.t)
+          Thanks to Florian Ragwitz and Vincent Pit for identifying
+          this.
+
+        * BUGFIX: autodie once again correctly works when used
+          inside a string eval.  (This was accidently broken
+          somewhere around 1.997-1.998).
+
+2.05  Sat Jul  4 16:33:01 AUSEST 2009
 
         * BUGFIX: format_default() in autodie::exception no longer
           returns a string with file and line attached.  This would

Modified: branches/upstream/libautodie-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libautodie-perl/current/MANIFEST?rev=39417&op=diff
==============================================================================
--- branches/upstream/libautodie-perl/current/MANIFEST (original)
+++ branches/upstream/libautodie-perl/current/MANIFEST Mon Jul  6 17:25:46 2009
@@ -75,6 +75,8 @@
 t/repeat.t
 t/scope_leak.t
 t/socket.t
+t/string-eval-basic.t
+t/string-eval-leak.t
 t/sysopen.t
 t/system.t
 t/truncate.t

Modified: branches/upstream/libautodie-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libautodie-perl/current/META.yml?rev=39417&op=diff
==============================================================================
--- branches/upstream/libautodie-perl/current/META.yml (original)
+++ branches/upstream/libautodie-perl/current/META.yml Mon Jul  6 17:25:46 2009
@@ -27,4 +27,4 @@
   bugtracker: http://rt.cpan.org/NoAuth/Bugs.html?Dist=autodie
   license: http://dev.perl.org/licenses/
   repository: http://github.com/pfenwick/autodie/tree/master
-version: 2.05
+version: 2.06

Modified: branches/upstream/libautodie-perl/current/lib/Fatal.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libautodie-perl/current/lib/Fatal.pm?rev=39417&op=diff
==============================================================================
--- branches/upstream/libautodie-perl/current/lib/Fatal.pm (original)
+++ branches/upstream/libautodie-perl/current/lib/Fatal.pm Mon Jul  6 17:25:46 2009
@@ -39,7 +39,7 @@
 use constant MIN_IPC_SYS_SIMPLE_VER => 0.12;
 
 # All the Fatal/autodie modules share the same version number.
-our $VERSION = '2.05';
+our $VERSION = '2.06';
 
 our $Debug ||= 0;
 
@@ -100,6 +100,7 @@
     ':2.03'  => [qw(:default)],
     ':2.04'  => [qw(:default)],
     ':2.05'  => [qw(:default)],
+    ':2.06'  => [qw(:default)],
 );
 
 $TAGS{':all'}  = [ keys %TAGS ];
@@ -1086,9 +1087,18 @@
 
                 my \$caller_level = 0;
 
-                while ( (caller \$caller_level)[1] =~ m{^\\(eval \\d+\\)\$} ) {
+                my \$caller;
+
+                while ( (\$caller = (caller \$caller_level)[1]) =~ m{^\\(eval \\d+\\)\$} ) {
+
+                    # If our filename is actually an eval, and we
+                    # reach it, then go to our autodying code immediatately.
+
+                    goto &\$code if (\$caller eq \$filename);
                     \$caller_level++;
                 }
+
+                # We're now out of the eval stack.
 
                 # If we're called from the correct file, then use the
                 # autodying code.

Modified: branches/upstream/libautodie-perl/current/lib/autodie.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libautodie-perl/current/lib/autodie.pm?rev=39417&op=diff
==============================================================================
--- branches/upstream/libautodie-perl/current/lib/autodie.pm (original)
+++ branches/upstream/libautodie-perl/current/lib/autodie.pm Mon Jul  6 17:25:46 2009
@@ -8,7 +8,7 @@
 our $VERSION;
 
 BEGIN {
-    $VERSION = '2.05';
+    $VERSION = '2.06';
 }
 
 use constant ERROR_WRONG_FATAL => q{
@@ -351,11 +351,6 @@
 is used with package filehandles (eg, C<FILE>).  Scalar filehandles are
 strongly recommended instead.
 
-Under Perl 5.8 only, C<autodie> I<does not> propagate into string C<eval>
-statements, although it can be explicitly enabled inside a string
-C<eval>.  This bug does not affect block C<eval> statements in
-any version of Perl.
-
 When using C<autodie> or C<Fatal> with user subroutines, the
 declaration of those subroutines must appear before the first use of
 C<Fatal> or C<autodie>, or have been exported from a module.
@@ -365,6 +360,31 @@
 Due to a bug in Perl, C<autodie> may "lose" any format which has the
 same name as an autodying built-in or function.
 
+C<autodie> may not work correctly if used inside a file with a
+name that looks like a string eval, such as F<eval (3)>.
+
+=head2 autodie and string eval
+
+Due to the current implementation of C<autodie>, unexpected results
+may be seen when used near or with the string version of eval.
+I<None of these bugs exist when using block eval>.
+
+Under Perl 5.8 only, C<autodie> I<does not> propagate into string C<eval>
+statements, although it can be explicitly enabled inside a string
+C<eval>.
+
+Under Perl 5.10 only, C<autodie> I<does not> operate correctly when
+used inside a string C<eval>.
+
+Under Perl 5.10 only, using a string eval when C<autodie> is in
+effect can cause the autodie behaviour to leak into the surrounding
+scope.  This can be worked around by using a C<no autodie> at the
+end of the scope to explicitly remove autodie's effects, or by
+avoiding the use of string eval.
+
+I<None of these bugs exist when using block eval>.  The use of
+C<autodie> with block eval is considered good practice.
+
 =head2 REPORTING BUGS
 
 Please report bugs via the CPAN Request Tracker at

Modified: branches/upstream/libautodie-perl/current/lib/autodie/exception.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libautodie-perl/current/lib/autodie/exception.pm?rev=39417&op=diff
==============================================================================
--- branches/upstream/libautodie-perl/current/lib/autodie/exception.pm (original)
+++ branches/upstream/libautodie-perl/current/lib/autodie/exception.pm Mon Jul  6 17:25:46 2009
@@ -14,7 +14,7 @@
 
 use if ($] >= 5.010), overload => '~~'  => "matches";
 
-our $VERSION = '2.05';
+our $VERSION = '2.06';
 
 my $PACKAGE = __PACKAGE__;  # Useful to have a scalar for hash keys.
 

Modified: branches/upstream/libautodie-perl/current/lib/autodie/exception/system.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libautodie-perl/current/lib/autodie/exception/system.pm?rev=39417&op=diff
==============================================================================
--- branches/upstream/libautodie-perl/current/lib/autodie/exception/system.pm (original)
+++ branches/upstream/libautodie-perl/current/lib/autodie/exception/system.pm Mon Jul  6 17:25:46 2009
@@ -5,7 +5,7 @@
 use base 'autodie::exception';
 use Carp qw(croak);
 
-our $VERSION = '2.05';
+our $VERSION = '2.06';
 
 my $PACKAGE = __PACKAGE__;
 

Modified: branches/upstream/libautodie-perl/current/lib/autodie/hints.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libautodie-perl/current/lib/autodie/hints.pm?rev=39417&op=diff
==============================================================================
--- branches/upstream/libautodie-perl/current/lib/autodie/hints.pm (original)
+++ branches/upstream/libautodie-perl/current/lib/autodie/hints.pm Mon Jul  6 17:25:46 2009
@@ -5,7 +5,7 @@
 
 use constant PERL58 => ( $] < 5.009 );
 
-our $VERSION = '2.05';
+our $VERSION = '2.06';
 
 =head1 NAME
 

Added: branches/upstream/libautodie-perl/current/t/string-eval-basic.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libautodie-perl/current/t/string-eval-basic.t?rev=39417&op=file
==============================================================================
--- branches/upstream/libautodie-perl/current/t/string-eval-basic.t (added)
+++ branches/upstream/libautodie-perl/current/t/string-eval-basic.t Mon Jul  6 17:25:46 2009
@@ -1,0 +1,24 @@
+#!/usr/bin/perl -w
+use strict;
+use warnings;
+use Test::More tests => 3;
+
+use constant NO_SUCH_FILE => 'this_file_had_better_not_exist';
+
+# Keep this test alone in its file as it can be hidden by using autodie outside
+# the eval.
+
+# Just to make sure we're absolutely not encountering any weird $@ clobbering
+# events, we'll capture a result from our string eval.
+
+my $result = eval q{
+    use autodie "open";
+
+    open(my $fh, '<', NO_SUCH_FILE);
+
+    1;
+};
+
+ok( ! $result, "Eval should fail with autodie/no such file");
+ok($@, "enabling autodie in string eval should throw an exception");
+isa_ok($@, 'autodie::exception');

Propchange: branches/upstream/libautodie-perl/current/t/string-eval-basic.t
------------------------------------------------------------------------------
    svn:executable = *

Added: branches/upstream/libautodie-perl/current/t/string-eval-leak.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libautodie-perl/current/t/string-eval-leak.t?rev=39417&op=file
==============================================================================
--- branches/upstream/libautodie-perl/current/t/string-eval-leak.t (added)
+++ branches/upstream/libautodie-perl/current/t/string-eval-leak.t Mon Jul  6 17:25:46 2009
@@ -1,0 +1,39 @@
+#!/usr/bin/perl -w
+use strict;
+use warnings;
+use Test::More tests => 2;
+
+# Under Perl 5.10.x, a string eval can cause a copy to be taken of
+# %^H, which delays stringification of our scope guard objects,
+# which in turn causes autodie to leak.  These tests check to see
+# if we've successfully worked around this issue.
+
+eval {
+
+    {
+        use autodie;
+        eval "1";
+    }
+
+    open(my $fh, '<', 'this_file_had_better_not_exist');
+};
+
+TODO: {
+    local $TODO;
+
+    if ( $] >= 5.010 ) {
+        $TODO = "Autodie can leak near string evals in 5.10.x";
+    }
+
+    is("$@","","Autodie should not leak out of scope");
+}
+
+# However, we can plug the leak with 'no autodie'.
+
+no autodie;
+
+eval {
+    open(my $fh, '<', 'this_file_had_better_not_exist');
+};
+
+is("$@","",'no autodie should be able to workaround this bug');

Propchange: branches/upstream/libautodie-perl/current/t/string-eval-leak.t
------------------------------------------------------------------------------
    svn:executable = *




More information about the Pkg-perl-cvs-commits mailing list