In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/fd2709db56c97e05ef8ae1f7c0f586d6f61103c2?hp=0b81c0dda6db9e4b1756ad9c7269e34b793dced7>
- Log ----------------------------------------------------------------- commit fd2709db56c97e05ef8ae1f7c0f586d6f61103c2 Author: Father Chrysostomos <[email protected]> Date: Sat Nov 15 13:31:40 2014 -0800 Fix double free with unterminated /(?{ <<END })/ If we are parsing from a stream (file), and we are inside a quote-like operator, and we find a here-doc marker that tries to extract the here-doc body from the stream (this is the last line of the quote-like operator, or it only has one line), and the the here-doc terminator cannot be found, then we end up trying to free a scalar twice: $ ./miniperl -e '"${ print <<END"' Can't find string terminator "END" anywhere before EOF at -e line 1. Attempt to free temp prematurely: SV 0x7fcafb82fd98, Perl interpreter: 0x7fcafb803200 at -e line 1. Attempt to free unreferenced scalar: SV 0x7fcafb82fd98, Perl interpreter: 0x7fcafb803200 at -e line 1. I caused that in v5.17.3-187-g3328ab5. The current line of code in the parser is usually stored in PL_parser->linestr (aka PL_linestr) and gets freed when the parser itself is freed. The heredoc parser, when extracting the body from a stream, tempor- arily sets aside PL_linestr, replacing it with another SV. If it doesnât find the terminator, it frees the PL_linestr value that has been set aside, under the assumption that parser_free will take care of freeing the new value. Inside quote-like operators that does not work, because PL_linestr has been localised and set to a new value, already prospectively freed via SAVEFREESV, in sublex_push. So we canât free that value again. M t/lib/croak/toke M toke.c commit b85eb6ecc6b729be41fd6c568a0e3611e2325e17 Author: Chad Granum <[email protected]> Date: Sat Nov 15 06:39:19 2014 -0800 Update Test-Simple to alpha 074 M cpan/Test-Simple/lib/Test/Builder.pm M cpan/Test-Simple/lib/Test/Builder/Module.pm M cpan/Test-Simple/lib/Test/Builder/Tester.pm M cpan/Test-Simple/lib/Test/Builder/Tester/Color.pm M cpan/Test-Simple/lib/Test/More.pm M cpan/Test-Simple/lib/Test/Simple.pm M cpan/Test-Simple/lib/Test/Stream.pm M cpan/Test-Simple/lib/Test/Stream/Context.pm M cpan/Test-Simple/lib/Test/Tester.pm M cpan/Test-Simple/lib/Test/use/ok.pm M cpan/Test-Simple/lib/ok.pm ----------------------------------------------------------------------- Summary of changes: cpan/Test-Simple/lib/Test/Builder.pm | 2 +- cpan/Test-Simple/lib/Test/Builder/Module.pm | 2 +- cpan/Test-Simple/lib/Test/Builder/Tester.pm | 2 +- cpan/Test-Simple/lib/Test/Builder/Tester/Color.pm | 2 +- cpan/Test-Simple/lib/Test/More.pm | 15 +++++++++------ cpan/Test-Simple/lib/Test/Simple.pm | 4 ++-- cpan/Test-Simple/lib/Test/Stream.pm | 2 +- cpan/Test-Simple/lib/Test/Stream/Context.pm | 2 ++ cpan/Test-Simple/lib/Test/Tester.pm | 2 +- cpan/Test-Simple/lib/Test/use/ok.pm | 2 +- cpan/Test-Simple/lib/ok.pm | 2 +- t/lib/croak/toke | 5 +++++ toke.c | 9 ++++++++- 13 files changed, 34 insertions(+), 17 deletions(-) diff --git a/cpan/Test-Simple/lib/Test/Builder.pm b/cpan/Test-Simple/lib/Test/Builder.pm index 434cc13..3ccff2f 100644 --- a/cpan/Test-Simple/lib/Test/Builder.pm +++ b/cpan/Test-Simple/lib/Test/Builder.pm @@ -4,7 +4,7 @@ use 5.008001; use strict; use warnings; -our $VERSION = '1.301001_073'; +our $VERSION = '1.301001_074'; $VERSION = eval $VERSION; ## no critic (BuiltinFunctions::ProhibitStringyEval) diff --git a/cpan/Test-Simple/lib/Test/Builder/Module.pm b/cpan/Test-Simple/lib/Test/Builder/Module.pm index 6f3bb6f..f7b58ff 100644 --- a/cpan/Test-Simple/lib/Test/Builder/Module.pm +++ b/cpan/Test-Simple/lib/Test/Builder/Module.pm @@ -8,7 +8,7 @@ use Test::Builder 0.99; require Exporter; our @ISA = qw(Exporter); -our $VERSION = '1.301001_073'; +our $VERSION = '1.301001_074'; $VERSION = eval $VERSION; ## no critic (BuiltinFunctions::ProhibitStringyEval) diff --git a/cpan/Test-Simple/lib/Test/Builder/Tester.pm b/cpan/Test-Simple/lib/Test/Builder/Tester.pm index 4df5a43..43b6b9a 100644 --- a/cpan/Test-Simple/lib/Test/Builder/Tester.pm +++ b/cpan/Test-Simple/lib/Test/Builder/Tester.pm @@ -1,7 +1,7 @@ package Test::Builder::Tester; use strict; -our $VERSION = '1.301001_073'; +our $VERSION = '1.301001_074'; $VERSION = eval $VERSION; ## no critic (BuiltinFunctions::ProhibitStringyEval) use Test::Stream 1.301001 '-internal'; diff --git a/cpan/Test-Simple/lib/Test/Builder/Tester/Color.pm b/cpan/Test-Simple/lib/Test/Builder/Tester/Color.pm index 0d932d3..e774334 100644 --- a/cpan/Test-Simple/lib/Test/Builder/Tester/Color.pm +++ b/cpan/Test-Simple/lib/Test/Builder/Tester/Color.pm @@ -1,7 +1,7 @@ package Test::Builder::Tester::Color; use strict; -our $VERSION = '1.301001_073'; +our $VERSION = '1.301001_074'; $VERSION = eval $VERSION; ## no critic (BuiltinFunctions::ProhibitStringyEval) use Test::Stream 1.301001 '-internal'; diff --git a/cpan/Test-Simple/lib/Test/More.pm b/cpan/Test-Simple/lib/Test/More.pm index f25bc9c..2f9aadf 100644 --- a/cpan/Test-Simple/lib/Test/More.pm +++ b/cpan/Test-Simple/lib/Test/More.pm @@ -4,7 +4,7 @@ use 5.008001; use strict; use warnings; -our $VERSION = '1.301001_073'; +our $VERSION = '1.301001_074'; $VERSION = eval $VERSION; ## no critic (BuiltinFunctions::ProhibitStringyEval) use Test::Stream 1.301001 '-internal'; @@ -442,8 +442,8 @@ Test::More - The defacto standard in unit testing tools. =head1 SYNOPSIS - # Enabled forking, and removes expensive legacy support - # Also provides context(), cull(), and tap_encoding() + # Using Test::Stream BEFORE using Test::More removes expensive legacy + # support. This Also provides context(), cull(), and tap_encoding() use Test::Stream; # Load after Test::Stream to get the benefits of removed legacy @@ -591,13 +591,16 @@ This is safer than and replaces the "no_plan" plan. =head2 Test::Stream -When you use Test::Stream, it enables support for forking in your tests. If it -is loaded before Test::More then it will prevent the insertion of some legacy -support shims, saving you memory and improving performance. +If Test::Stream is loaded before Test::More then it will prevent the insertion +of some legacy support shims, saving you memory and improving performance. use Test::Stream; use Test::More; +You can also use it to make forking work: + + use Test::Stream 'enable_fork'; + =head2 TAP Encoding You can now control the encoding of your TAP output using Test::Stream. diff --git a/cpan/Test-Simple/lib/Test/Simple.pm b/cpan/Test-Simple/lib/Test/Simple.pm index a090867..57d0ff3 100644 --- a/cpan/Test-Simple/lib/Test/Simple.pm +++ b/cpan/Test-Simple/lib/Test/Simple.pm @@ -5,10 +5,10 @@ use 5.008001; use strict; use warnings; -our $VERSION = '1.301001_073'; +our $VERSION = '1.301001_074'; $VERSION = eval $VERSION; ## no critic (BuiltinFunctions::ProhibitStringyEval) -use Test::Stream 1.301001_073 '-internal'; +use Test::Stream 1.301001_074 '-internal'; use Test::Stream::Toolset; use Test::Stream::Exporter; diff --git a/cpan/Test-Simple/lib/Test/Stream.pm b/cpan/Test-Simple/lib/Test/Stream.pm index 989f33d..ce9eca0 100644 --- a/cpan/Test-Simple/lib/Test/Stream.pm +++ b/cpan/Test-Simple/lib/Test/Stream.pm @@ -2,7 +2,7 @@ package Test::Stream; use strict; use warnings; -our $VERSION = '1.301001_073'; +our $VERSION = '1.301001_074'; $VERSION = eval $VERSION; ## no critic (BuiltinFunctions::ProhibitStringyEval) use Test::Stream::Context qw/context/; diff --git a/cpan/Test-Simple/lib/Test/Stream/Context.pm b/cpan/Test-Simple/lib/Test/Stream/Context.pm index 5bbe2f1..5b17d42 100644 --- a/cpan/Test-Simple/lib/Test/Stream/Context.pm +++ b/cpan/Test-Simple/lib/Test/Stream/Context.pm @@ -334,6 +334,8 @@ sub register_event { | || die $@; } +sub meta { is_tester($_[0]->[FRAME]->[0]) } + sub hide_todo { my $self = shift; no strict 'refs'; diff --git a/cpan/Test-Simple/lib/Test/Tester.pm b/cpan/Test-Simple/lib/Test/Tester.pm index 6f68770..cb56448 100644 --- a/cpan/Test-Simple/lib/Test/Tester.pm +++ b/cpan/Test-Simple/lib/Test/Tester.pm @@ -16,7 +16,7 @@ require Exporter; use vars qw( @ISA @EXPORT $VERSION ); -our $VERSION = '1.301001_073'; +our $VERSION = '1.301001_074'; $VERSION = eval $VERSION; ## no critic (BuiltinFunctions::ProhibitStringyEval) @EXPORT = qw( run_tests check_tests check_test cmp_results show_space ); diff --git a/cpan/Test-Simple/lib/Test/use/ok.pm b/cpan/Test-Simple/lib/Test/use/ok.pm index 5e64485..ee5ebb7 100644 --- a/cpan/Test-Simple/lib/Test/use/ok.pm +++ b/cpan/Test-Simple/lib/Test/use/ok.pm @@ -3,7 +3,7 @@ use strict; use warnings; use 5.005; -our $VERSION = '1.301001_073'; +our $VERSION = '1.301001_074'; $VERSION = eval $VERSION; ## no critic (BuiltinFunctions::ProhibitStringyEval) use Test::Stream 1.301001 '-internal'; diff --git a/cpan/Test-Simple/lib/ok.pm b/cpan/Test-Simple/lib/ok.pm index f244019..849f89e 100644 --- a/cpan/Test-Simple/lib/ok.pm +++ b/cpan/Test-Simple/lib/ok.pm @@ -6,7 +6,7 @@ use Test::Stream 1.301001 '-internal'; use Test::More 1.301001 (); use Test::Stream::Carp qw/croak/; -our $VERSION = '1.301001_073'; +our $VERSION = '1.301001_074'; $VERSION = eval $VERSION; ## no critic (BuiltinFunctions::ProhibitStringyEval) sub import { diff --git a/t/lib/croak/toke b/t/lib/croak/toke index 2711c50..26fc8c7 100644 --- a/t/lib/croak/toke +++ b/t/lib/croak/toke @@ -29,6 +29,11 @@ eval "s//<<foo/e"; die $@ EXPECT Can't find string terminator "foo" anywhere before EOF at (eval 1) line 1. ######## +# NAME Unterminated here-doc in string +"${<<foo"; # Used to give âAttempt to free blah blah blahâ +EXPECT +Can't find string terminator "foo" anywhere before EOF at - line 1. +######## # NAME Unterminated qw// qw/ EXPECT diff --git a/toke.c b/toke.c index 74dd1c1..b6da013 100644 --- a/toke.c +++ b/toke.c @@ -9277,7 +9277,14 @@ S_scan_heredoc(pTHX_ char *s) origline + 1 + PL_parser->herelines); if (!lex_next_chunk(LEX_NO_TERM) && (!SvCUR(tmpstr) || SvEND(tmpstr)[-1] != '\n')) { - SvREFCNT_dec(linestr_save); + /* Simply freeing linestr_save might seem simpler here, as it + does not matter what PL_linestr points to, since we are + about to croak; but in a quote-like op, linestr_save + will have been prospectively freed already, via + SAVEFREESV(PL_linestr) in sublex_push, so itâs easier to + restore PL_linestr. */ + SvREFCNT_dec_NN(PL_linestr); + PL_linestr = linestr_save; goto interminable; } CopLINE_set(PL_curcop, origline); -- Perl5 Master Repository
