develooper Front page | perl.perl5.porters | Postings from August 2004

RE: [perl #18819] regular expression hanging

Thread Next
From:
Harry Pulley
Date:
August 27, 2004 04:13
Subject:
RE: [perl #18819] regular expression hanging
Message ID:
610C0DAE7B14D31193A90060943F3D0A0D0F7DBD@hqntexch.mks.com
Hi Steve,

It's been nearly two years since I sent this bug report but I do still believe it is a bug.  That code didn't hang long ago but has now been hanging for the last couple of released versions.  The test code snippet was culled from a big problem one of our customers was having.  That customer certainly considers it a bug but I wasn't involved until final developer level support so I didn't have the opportunity to ask them why they were using that particular regular expression syntax, only to confirm that it used to work in an earlier perl port but started to fail in our 5.6 port.

I was never asked to fix the bug myself so it was never fixed here.

Harry

-----Original Message-----
From: Steve Peters via RT [mailto:perlbug-followup@perl.org]
Sent: Thursday, August 26, 2004 11:14 AM
To: Harry Pulley
Subject: [perl #18819] regular expression hanging 


> [hpulley@mks.com - Mon Dec 02 10:10:49 2002]:
> 
> I am looking at fixing this bug and will send a patch if I'm
>    successful but in
> the meantime, I thought I would send this report.
> 
> The following code hangs after the output of one line with Perl 5.6
>    and 5.8.
> I've tried ActivePerl 5.6 and 5.8 and our (MKS Toolkit's) Perl 5.6 and
>    5.8 and
> both exhibit the same behaviour.  Both ActivePerl and the MKS Port
>    worked fine
> at 5.0.5.
> 
>  $procName="This is a test on a Win platform #  jj # - - __ _ * * * #
>    # #";
> while ($procName =~ /\G([\w]+)|([\s]+)|([^\w\x]+)/g)
>     {
>  if (defined $1) { print " ONE $1 \n";}
>   if (defined $3)
>      {
>       print "THREE $3 \n";
>      }
>  }
> 
> Output from ActivePerl 5.8's perlbug -d:
> ---

From what I can see, the regular expression is not valid.  With warnings
and strict on, I get the following warning while the program runs:

Illegal hexadecimal digit ']' ignored at ./regex.pl line 8.

From what I can see, the regex continuously matches the "[\s]+", so it
does not hang, but instead goes into an infinite loop.  Since I've never
really used "\G" before in a regexp, I'm not sure if this is the
expected behavior or not.  Looking at perlre, there are some issues with
\G.  Is the behavior in this ticket actually a bug?

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