Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Perl: porters

[PATCHES] Fix + test bug #70091

 

 

Perl porters RSS feed   Index | Next | Previous | View Threaded


gerard at ggoossen

Nov 24, 2009, 3:50 AM

Post #1 of 2 (234 views)
Permalink
[PATCHES] Fix + test bug #70091

Attached are three patches:
- Adding an assertion to padav and padhv to make sure the lexical variable
is of the correct type, making the bug more obvious.
- The actual fix, whitespace is also ignored when the are brackets even
when interpolation.
- Adding a simplified version of the bug. Because I couldn't find a good
place to put it, I created a new test in "t/lex/interpolate.t"

Gerard Goossen
Attachments: 0001-Add-assertions-that-pp_padav-and-pp_padhv-push-scala.patch (0.85 KB)
  0002-Also-skip-spaces-after-variable-if-we-are-within-lex.patch (0.73 KB)
  0003-add-interpolation-test.patch (1.91 KB)


jesse at fsck

Nov 25, 2009, 11:33 AM

Post #2 of 2 (195 views)
Permalink
Re: [PATCHES] Fix + test [perl #70091] [In reply to]

Thanks. Applied. Though based on discussions with a couple other
porters, I opted not to create a new toplevel test directory, so the
tests got moved around. Also, for the future, it'd be great if tests
that test specific bugs include the bug # in the test file or message.

...and actually, it's worth mentioning that if you use [perl #xxxxx]
syntax in your subject line, your message gets automatically appended to
the bug, which is useful.

Best,
Jesse


On Tue 24.Nov'09 at 12:50:16 +0100, Gerard Goossen wrote:
> Attached are three patches:
> - Adding an assertion to padav and padhv to make sure the lexical variable
> is of the correct type, making the bug more obvious.
> - The actual fix, whitespace is also ignored when the are brackets even
> when interpolation.
> - Adding a simplified version of the bug. Because I couldn't find a good
> place to put it, I created a new test in "t/lex/interpolate.t"
>
> Gerard Goossen

> From 4cebc69f48b708aac8faaa2771c037d4b7cfbfd8 Mon Sep 17 00:00:00 2001
> From: Gerard Goossen <gerard [at] ggoossen>
> Date: Tue, 24 Nov 2009 11:27:04 +0100
> Subject: [PATCH 1/3] Add assertions that pp_padav and pp_padhv push scalars of the correct type.
>
> ---
> pp.c | 2 ++
> 1 files changed, 2 insertions(+), 0 deletions(-)
>
> diff --git a/pp.c b/pp.c
> index b271e7b..292feb6 100644
> --- a/pp.c
> +++ b/pp.c
> @@ -63,6 +63,7 @@ PP(pp_padav)
> {
> dVAR; dSP; dTARGET;
> I32 gimme;
> + assert(SvTYPE(TARG) == SVt_PVAV);
> if (PL_op->op_private & OPpLVAL_INTRO)
> if (!(PL_op->op_private & OPpPAD_STATE))
> SAVECLEARSV(PAD_SVl(PL_op->op_targ));
> @@ -106,6 +107,7 @@ PP(pp_padhv)
> dVAR; dSP; dTARGET;
> I32 gimme;
>
> + assert(SvTYPE(TARG) == SVt_PVHV);
> XPUSHs(TARG);
> if (PL_op->op_private & OPpLVAL_INTRO)
> if (!(PL_op->op_private & OPpPAD_STATE))
> --
> 1.6.5
>

> From eb872e07a2a07075efbfaa3d8a2776c0aa762272 Mon Sep 17 00:00:00 2001
> From: Gerard Goossen <gerard [at] ggoossen>
> Date: Tue, 24 Nov 2009 12:06:55 +0100
> Subject: [PATCH 2/3] Also skip spaces after variable if we are within lexical brackets.
> Fixes #70091: Segmentation fault in hash lookup in regex substitution
>
> ---
> toke.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/toke.c b/toke.c
> index a4e9471..f214ddf 100644
> --- a/toke.c
> +++ b/toke.c
> @@ -5441,7 +5441,7 @@ Perl_yylex(pTHX)
> d = s;
> {
> const char tmp = *s;
> - if (PL_lex_state == LEX_NORMAL)
> + if (PL_lex_state == LEX_NORMAL || PL_lex_brackets)
> s = SKIPSPACE1(s);
>
> if ((PL_expect != XREF || PL_oldoldbufptr == PL_last_lop)
> --
> 1.6.5
>

> From d0d0240615a8364b270972683f449d8504c10700 Mon Sep 17 00:00:00 2001
> From: Gerard Goossen <gerard [at] ggoossen>
> Date: Tue, 24 Nov 2009 12:13:13 +0100
> Subject: [PATCH 3/3] add interpolation test
>
> ---
> MANIFEST | 1 +
> t/TEST | 2 +-
> t/lex/interpolate.t | 15 +++++++++++++++
> 3 files changed, 17 insertions(+), 1 deletions(-)
> create mode 100644 t/lex/interpolate.t
>
> diff --git a/MANIFEST b/MANIFEST
> index bc4460d..7300aef 100644
> --- a/MANIFEST
> +++ b/MANIFEST
> @@ -4234,6 +4234,7 @@ t/io/tell.t See if file seeking works
> t/io/through.t See if pipe passes data intact
> t/io/utf8.t See if file seeking works
> t/japh/abigail.t Obscure tests
> +t/lex/interpolate.t See if interpolating strings work
> t/lib/1_compile.t See if the various libraries and extensions compile
> t/lib/Cname.pm Test charnames in regexes (op/pat.t)
> t/lib/common.pl Helper for lib/{warnings,feature}.t
> diff --git a/t/TEST b/t/TEST
> index 6124c5d..b8dc4c2 100755
> --- a/t/TEST
> +++ b/t/TEST
> @@ -411,7 +411,7 @@ unless (@ARGV) {
> # then comp, to validate that require works
> # then run, to validate that -M works
> # then we know we can -MTestInit for everything else, making life simpler
> - foreach my $dir (qw(base comp run cmd io re op uni mro)) {
> + foreach my $dir (qw(base comp run cmd io lex re op uni mro)) {
> _find_tests($dir);
> }
> _find_tests("lib") unless $::core;
> diff --git a/t/lex/interpolate.t b/t/lex/interpolate.t
> new file mode 100644
> index 0000000..3472d97
> --- /dev/null
> +++ b/t/lex/interpolate.t
> @@ -0,0 +1,15 @@
> +BEGIN {
> + require "test.pl"
> +}
> +
> +use strict;
> +use warnings;
> +
> +plan 2;
> +
> +{
> + my %foo = (aap => "monkey");
> + my $foo = '';
> + is("@{[$foo{'aap'}]}", 'monkey', 'interpolation of hash lookup with space between lexical variable and subscript');
> + is("@{[$foo {'aap'}]}", 'monkey', 'interpolation of hash lookup with space between lexical variable and subscript');
> +}
> --
> 1.6.5
>
Attachments: signature.asc (0.19 KB)

Perl porters RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.