php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25798 forever-run or no-error-abort in preg_match
Submitted: 2003-10-08 14:04 UTC Modified: 2004-04-21 16:02 UTC
Votes:9
Avg. Score:5.0 ± 0.0
Reproduced:8 of 9 (88.9%)
Same Version:4 (50.0%)
Same OS:1 (12.5%)
From: musha dot yoshinori at nifty dot ne dot jp Assigned:
Status: Not a bug Package: PCRE related
PHP Version: 4.3.6 OS: Windows XP Pro
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
29 + 9 = ?
Subscribe to this entry?

 
 [2003-10-08 14:04 UTC] musha dot yoshinori at nifty dot ne dot jp
Description:
------------
PHP aborts without any message or runs forever in below case.
Platform: Windows XP Pro, Apache2.0.46, PHP4.3.3

For example, in preg_match('/a(?:.)+z/',$str,$match), the length of string matched between 'a' and 'z' is more than approximately 1KB. It always appears. According to the length, PHP aborts without any message or runs forever.

It also appears in preg_match('/a(?>.)+z/',$str,$match), but does not appear in preg_match('/a(.)+z/',$str,$match) and preg_match('/a.+z/',$str,$match).

Actually, I want to use preg_match_all('/<tr[^>]*>((?>.(?!<\/tr>))+.)<\/tr>/is',$str,$matches) and so on.

Reproduce code:
---------------
$str =<<<EOD
a
nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
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esGit/SVN commitsRelated reports
 [2003-10-15 01:59 UTC] sniper@php.net
Reproduced with latest CVS (under Windows XP), PHP as Apache2 module. Works fine with CLI.

 [2004-01-19 23:51 UTC] musha dot yoshinori at nifty dot ne dot jp
I have tried to check the latest version, 4.3.5RC2-dev, http://snaps.php.net/win32/php4-win32-STABLE-latest.zip.
I'm sorry that it doesn't work well. The result doesn't change from previous versions.
 [2004-01-20 03:50 UTC] sniper@php.net
It's a PCRE limitation, NOT any bug in PHP..

 [2004-01-20 06:31 UTC] indy at indeyets dot pp dot ru
however, it works just fine on Apache-1 systems
 [2004-04-21 16:03 UTC] musha dot yoshinori at nifty dot ne dot jp
It does not work on PHP4.3.6, IIS5.1 or Apache2.0.46, and Windows XP pro, too.
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Thu Jun 24 05:01:24 2021 UTC