From:             pahan at hubbitus dot spb dot su
Operating system: Linux
PHP version:      5.3.0beta1
PHP Bug Type:     PCRE related
Bug description:  Segmentation fault in preg_replace on many repitition of 
pattern

Description:
------------
On text, where search pattern repeated many times (>643 times by test) php
segfaulted (Core dump you may download here:
http://ru.bir.ru/_temp/php-pcre-bug/core.8729 ) on preg_replace.

So, if we reduce length of test text (
http://ru.bir.ru/_temp/php-pcre-bug/pcre_bug.text ) on 1 line, or just
limit repetition on 1 - it is worked.

All Zend-modules was disabled.

Reproduce code:
---------------
<?
$text = file_get_contents('pcre_bug.text');

echo preg_replace('/(@@ -[\d,]+ \+[\d,]+ @@\s){2,}/s', '-some data-',
$text); //Segmentation fault
$text = file();

# Interesting:
#echo preg_replace('/(@@ -[\d,]+ \+[\d,]+ @@\s){2,642}/s', '-some data-',
$text); //Work, but result it is not same as needed.
#echo preg_replace('/(@@ -[\d,]+ \+[\d,]+ @@\s){2,643}/s', '-some data-',
$text); //PHP Warning:  preg_replace(): Compilation failed: regular
expression is too large at offset 33
?>

Expected result:
----------------
Work as when text is less.

Actual result:
--------------
Segmentation fault

-- 
Edit bug report at http://bugs.php.net/?id=47376&edit=1
-- 
Try a CVS snapshot (PHP 5.2):        
http://bugs.php.net/fix.php?id=47376&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):        
http://bugs.php.net/fix.php?id=47376&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):        
http://bugs.php.net/fix.php?id=47376&r=trysnapshot60
Fixed in CVS:                        
http://bugs.php.net/fix.php?id=47376&r=fixedcvs
Fixed in CVS and need be documented: 
http://bugs.php.net/fix.php?id=47376&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=47376&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=47376&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=47376&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=47376&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=47376&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=47376&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=47376&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=47376&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=47376&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=47376&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=47376&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=47376&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=47376&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=47376&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=47376&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=47376&r=mysqlcfg

Reply via email to