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

RE: [perl #134409] Perl intepreter exception on expressionsubstitution

Thread Previous | Thread Next
From:
Chris Crook
Date:
September 7, 2019 22:18
Subject:
RE: [perl #134409] Perl intepreter exception on expressionsubstitution
Message ID:
A87E66F06E86F14B857F2EB047CDF93231399101@prdassexch01.ad.linz.govt.nz
Hi James

Thanks for your quick response - always amazes me how well supported these tools are.  I couldn't spot current supported perl versions on the website.  I am using 5.22.1 whcih is current default on ubuntu 16.04.  The problem originally showed on ubuntu 18.04, perl version info below.

This is perl 5, version 26, subversion 1 (v5.26.1) built for x86_64-linux-gnu-thread-multi
(with 67 registered patches, see perl -V for more detail)

I'm not surprised you couldn't find the GDSearchSQLite anywhere (would have been surprised if you could).  I'll try and build a smaller test case/data set and then see if I can still reproduce it.  Next week I expect.

Thanks
Chris


-----Original Message-----
From: James E Keenan via RT [mailto:perlbug-followup@perl.org]
Sent: Friday, 6 September 2019 12:10 p.m.
To: Chris Crook
Subject: [perl #134409] Perl intepreter exception on expression substitution

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)

________________________________

This message contains information, which may be in confidence and may be subject to legal privilege. If you are not the intended recipient, you must not peruse, use, disseminate, distribute or copy this message. If you have received this message in error, please notify us immediately (Phone 0800 665 463 or info@linz.govt.nz) and destroy the original message. LINZ accepts no responsibility for changes to this email, or for any attachments, after its transmission from LINZ. Thank You.

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