#47376 [Opn->Bgs]: Segmentation fault in preg_replace on many repitition of pattern
| From: | felipe@php.net | Date: | Fri, 13 Feb 2009 00:53:14 +0000 |
| Subject: | #47376 [Opn->Bgs]: Segmentation fault in preg_replace on many repitition of pattern | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-133785@lists.php.net to get a copy of this message | ||
ID: 47376
Updated by: felipe@php.net
Reported By: pahan at hubbitus dot spb dot su
-Status: Open
+Status: Bogus
Bug Type: PCRE related
Operating System: Linux
PHP Version: 5.3.0beta1
New Comment:
It isn't a PHP bug.
See bug#33468, bug#39387.
Thanks.
Previous Comments:
------------------------------------------------------------------------
[2009-02-12 22:51:08] pahan at hubbitus dot spb dot su
Sorry, sorry. Off course line "$text = file();" in reproduce code
unnecessary. Please remove it.
------------------------------------------------------------------------
[2009-02-12 22:12:28] pahan at hubbitus dot spb dot su
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 this bug report at http://bugs.php.net/?id=47376&edit=1