DO NOT REPLY [Bug 14850] - Search gets frozen for a pattern

[email protected]
Newsgroups gmane.comp.jakarta.oro.devel
Message-ID <[email protected]>
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=14850>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=14850

Search gets frozen for a pattern

[email protected] changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID



------- Additional Comments From [email protected]  2002-11-26 14:24 -------
Although the behavior is not desirable, it is not quite a bug.  Both Perl
5.003_07 and Perl-5.005.03 behave the same way.  For example:

perl5.003_07/perl -e  '@foo=<STDIN>; $bar=join("", @foo); print "$bar"; if (
$bar =~ /package( +)((\w+|\W+)+)( +)is( +|\n)/) { print "MATCH!\n"; }' < foo.txt

and

perl-5.005.03/perl -e  '@foo=<STDIN>; $bar=join("", @foo); print "$bar"; if (
$bar =~ /package( +)((\w+|\W+)+)( +)is( +|\n)/) { print "MATCH!\n"; }' < foo.txt

where foo.txt contains:

----------------------------------
package "dlfk"."isam" is
 isa varchar2(10);
 
procedure isa_as;
end;
----------------------------------

This will be fixed as we move to Perl 5.6 compatibility, but right now, we
do the same as Perl 5.00x.

It is important to remember that regular expressions are state machines and
are not guaranteed to terminate.  You have to craft reasonable expressions
that do not result in excessive or even infinite backtracking and recursion.
The problem is easily solved by simplifying the regular expression to the
more accurate:
  package( +)((\w|\W)+)( +)is( +|\n)
Notice how (\w+|\W+)+ is equivalent to (\w|\W)+ in what it matches.  The
expression can be further simplified because "\w|\W" is equivalent to "."

We would rather you ask for help on oro-dev before using the bug reporting
system.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.