develooper Front page | perl.perl5.porters | Postings from September 2019

[perl #134409] Perl intepreter exception on expression substitution

Thread Previous | Thread Next
From:
James E Keenan via RT
Date:
September 6, 2019 00:10
Subject:
[perl #134409] Perl intepreter exception on expression substitution
Message ID:
rt-4.0.24-15798-1567728622-1887.134409-15-0@perl.org
On Fri, 06 Sep 2019 00:04:13 GMT, jkeenan wrote:
> On Thu, 05 Sep 2019 20:37:32 GMT, ccrook@linz.govt.nz wrote:
> > This is a bug report for perl from ccrook@linz.govt.nz,
> > generated with the help of perlbug 1.40 running under perl 5.22.1.
> >
> >
> > -----------------------------------------------------------------
> > [Please describe your issue here]
> >
> > Perl raises exception on search and replace:
> >
> > panic: sv_pos_b2u: bad byte offset, blen=20, byte=27 at
> > lib/GDSearchSQLite.pm line 81
> >

Also, I searched for 'GDSearchSQLite' in both DDG and the big internet search thing -- and came up with nothing significant.  Is this code publicly available?

> > 75  sub SubstituteSql
> > 76  {
> > 77     my ($sql,$lookup)=@_;
> > 78     my $updated_sql={};
> > 79     while( my($k,$v)=each(%$sql))
> > 80     {
> > 81         $v =~ s/\{(\w+)\}/$lookup->{$1}/eg;
> > 82         $updated_sql->{$k}=$v;
> > 83     }
> > 84     return $updated_sql;
> > 85  }
> >
> > Note: this is old code buried fairly deeply in CGI web source.  I was
> > able dump the inputs
> > to this specific routine, below, but in isolation this did not
> > trigger
> > the error.  So unfortunately
> > I am not able to provide a useful reproducible test case.
> >
> 
> As you probably can guess, this is going to make it difficult for us
> to diagnose your problem.
> 
> In addition, your ticket suggests that you were using perl 5.22.1.
> That's out of support.  Can you reproduce this problem using either
> perl-5.30 or a git checkout of the Perl 5 core distribution?
> 
> > I was able to work around this by replacing line 81 with the
> > following
> > lines (which
> > are equivalent in the context in which this is called - key is
> > defined
> > in code always
> > alpha, all strings {\w+} in $k have corresponding value in $lookup).
> >
> > 80         while( my($k1,$v1)=each(%$lookup) )
> > 81         {
> > 82             $v =~ s/\{$k1\}/$v1/eg;
> > 83         };
> >
> > Below: test code with offending input doesn't reproduces issue:
> >
> > use Data::Dumper;
> >
> > $sql = {
> >           'where' => 'gwdi{nword}.word {wordop} \'{word}\'',
> >           'table' => 'JOIN word_index gwdi{nword} ON
> > gwdi{nword}.geodetic_code=ati.geodetic_code'
> >         };
> > $lookup = {
> >           'wordop' => '=',
> >           'word' => 'SMITH',
> >           'nword' => 0
> >         };
> >
> >
> > sub SubstituteSql
> > {
> >    my ($sql,$lookup)=@_;
> >    use Data::Dumper;
> >    open(my $tf, ">>/tmp/badstuff");
> >    print $tf Dumper($sql);
> >    print $tf Dumper($lookup);
> >    close($tf);
> >    my $updated_sql={};
> >    while( my($k,$v)=each(%$sql))
> >    {
> >        $v =~ s/\{(\w+)\}/$lookup->{$1}/eg;
> >        $updated_sql->{$k}=$v;
> >    }
> >    return $updated_sql;
> > }
> >
> > print Dumper(SubstituteSql($sql,$lookup)),"\n";
> >


-- 
James E Keenan (jkeenan@cpan.org)

---
via perlbug:  queue: perl5 status: open
https://rt.perl.org/Ticket/Display.html?id=134409

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About