Skip Menu |

This queue is for tickets about the Regexp-Assemble CPAN distribution.

Report information
The Basics
Id: 28554
Status: resolved
Priority: 4/
Queue: Regexp-Assemble

People
Owner: dland [...] cpan.org
Requestors: david.morel [...] amakuru.net
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 0.31
Fixed in: 0.32



Subject: Segfault if '/' present in range when flags set
Short self-explainatory example: david@MoMac david $ perl -MRegexp::Assemble -e '$re=Regexp::Assemble->new();$re->flags ("xism");$re->add("[/?&;]");print $re' Segmentation fault david@MoMac david $ perl -MRegexp::Assemble -e '$re=Regexp::Assemble->new();$re->flags ("xism");$re->add("[?&;]");print $re' (?msix:[?&;]) Bug reproduced on various versions of 5.8 with latest version of R:A
From: dland [...] cpan.org
On Mon Jul 30 08:26:47 2007, david.morel@amakuru.net wrote: Show quoted text
> Short self-explainatory example: > > david@MoMac david $ perl -MRegexp::Assemble -e '$re=Regexp::Assemble-
> >new();$re->flags
> ("xism");$re->add("[/?&;]");print $re' > Segmentation fault > david@MoMac david $ perl -MRegexp::Assemble -e '$re=Regexp::Assemble-
> >new();$re->flags
> ("xism");$re->add("[?&;]");print $re' > (?msix:[?&;]) > > Bug reproduced on various versions of 5.8 with latest version of R:A
Eeeek! The following patch will correct this problem, and it's probably better anyway. --- /usr/local/lib/perl5/site_perl/5.8.8/Regexp/Assemble.pm Fri May 18 18:20:35 2007 +++ Assemble.pm Mon Jul 30 16:55:28 2007 @@ -977,7 +977,8 @@ else { # how could I not repeat myself? $self->{re} = length $self->{flags} - ? eval "qr/$str/$self->{flags}" + # eval "qr/$str/$self->{flags}" + ? qr/(?$self->{flags}:$str)/ : qr/$str/ ; } I introduced an eval block in _build_re() so that your resulting pattern would be just (?xism:[/?&;]) instead of (?-xism:(?xism:[/?&;])) ... because you cannot add flags to a qr// quoted string. I always thought this was kind of icky, so I shall back this change out in the next release. In the meantime, if you are able to apply to patch to your own file, this will be sufficient to get you going. Sorry about that, and thanks for taking the time to file the report. David Landgren
--- /usr/local/lib/perl5/site_perl/5.8.8/Regexp/Assemble.pm Fri May 18 18:20:35 2007 +++ Assemble.pm Mon Jul 30 16:55:28 2007 @@ -977,7 +977,8 @@ else { # how could I not repeat myself? $self->{re} = length $self->{flags} - ? eval "qr/$str/$self->{flags}" + # eval "qr/$str/$self->{flags}" + ? qr/(?$self->{flags}:$str)/ : qr/$str/ ; }
On Mon Jul 30 08:26:47 2007, david.morel@amakuru.net wrote: Show quoted text
> Short self-explainatory example: > > david@MoMac david $ perl -MRegexp::Assemble -e '$re=Regexp::Assemble-
> >new();$re->flags
> ("xism");$re->add("[/?&;]");print $re' > Segmentation fault > david@MoMac david $ perl -MRegexp::Assemble -e '$re=Regexp::Assemble-
> >new();$re->flags
> ("xism");$re->add("[?&;]");print $re' > (?msix:[?&;]) > > Bug reproduced on various versions of 5.8 with latest version of R:A
If you cannot apply the patch I posted in the other followup, you can use the following workaround: my $re=Regexp::Assemble->new()->flags("xism")->add("[?&;]"); my $str = $re->as_string; $re = qr/(?:$re->{flags}$str)/; A bit cumbersome, but it will do the right thing (regardless of whether flags contains anything or not). Thanks, David
This bug has been corrected in release 0.32, now available on CPAN. Thanks, David