Bug #54614 [Opn]: Trivial RE failure: /([^b]*a*)*$/

From: Date: Wed, 27 Apr 2011 19:15:36 +0000
Subject: Bug #54614 [Opn]: Trivial RE failure: /([^b]*a*)*$/
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-160399@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=54614&edit=1

 ID:                 54614
 User updated by:    php at richardneill dot org
 Reported by:        php at richardneill dot org
 Summary:            Trivial RE failure:  /([^b]*a*)*$/
 Status:             Open
 Type:               Bug
 Package:            *Regular Expressions
 Operating System:   Linux
 PHP Version:        5.3.6
 Block user comment: N
 Private report:     N

 New Comment:

A slightly simpler test case is:
  $contents =  "aaaaaaaab";
  $search = '/(a*a*)*$/';


Previous Comments:
------------------------------------------------------------------------
[2011-04-27 18:43:02] php at richardneill dot org

Description:
------------
If I search in the string :   'aaaaaaaab'
with the RE:   '/([^b]*a*)*$/'

then preg_replace fails with a backtrack-limit error. (error 2)
I have backtrack.limit configured to 32MB, so something is very wrong.

The example fails on several different PHP versions, CPU architectures
and Linux
Distros.  However, using Perl for the same RE works fine.

Test script:
---------------
$contents =  "aaaaaaaab";
$search = '/([^b]*a*)*$/';
$result = preg_replace($search,"x",$contents);
if ($result === NULL){
	echo "preg failed, error is ".preg_last_error()."\n";
}else{
	echo "success\n";
}

Expected result:
----------------
preg_replace shouldn't fail.

Actual result:
--------------
preg_replace returns NULL, and preg_last_error returns 2.


------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=54614&edit=1


Thread (6 messages)

« previous php.bugs (#160399) next »