#47811 [Asn->Bgs]: preg_match that can cause segmentation fault
| From: | nlopess@php.net | Date: | Tue, 14 Apr 2009 20:56:24 +0000 |
| Subject: | #47811 [Asn->Bgs]: preg_match that can cause segmentation fault | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-135826@lists.php.net to get a copy of this message | ||
ID: 47811
Updated by: nlopess@php.net
Reported By: travis at wikihow dot com
-Status: Assigned
+Status: Bogus
Bug Type: Reproducible crash
Operating System: CentOS release 4.4 & Mac OS 10.4
PHP Version: 5.2.9
Assigned To: nlopess
New Comment:
Felipe is right. This is not a bug, just the expected stack overflow.
You can "fix" the problem by increasing the stack size.
Previous Comments:
------------------------------------------------------------------------
[2009-04-02 12:39:01] felipe@php.net
This stack overflow is expected. See the earlies bug reports.
------------------------------------------------------------------------
[2009-04-02 12:27:26] Phil dot H at gmx dot net
Another php preg_match crash using php 5.2.9-1 on Windows XP and
2003R2:
<?php
$string = str_repeat('blub ', 100000);
$regexp = '/ \G (?P<text> (?:.(?!\[% ))*.(?=\[%| $))/isx';
if (preg_match($regexp, $string, $aMatches, PREG_OFFSET_CAPTURE, 0)) {
echo "matched\n";
}
echo "finished";
?>
------------------------------------------------------------------------
[2009-03-30 12:22:15] pajoye@php.net
Nuno, can you take a look please? Can reproduce it here too.
------------------------------------------------------------------------
[2009-03-30 11:24:40] scope at planetavent dot de
Here's another snippet:
<?php
$s =
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$pattern = "@(X)*@";
$return = preg_match( $pattern, $s );
echo $return;
?>
This one crashes apache 2.2.8 and 2.2.11 with php-5.2.9 and php-5.2.9-1
on windows 2003.
------------------------------------------------------------------------
[2009-03-27 23:53:44] dennis dot birkholz at nexxes dot net
I have a similar segfault testcase for preg_match. It always crashes at
a stringlength of around 6700. PHP is 5.2.8 on gentoo linux.
# Create my test-string
for ($i=0; $i<20000; $i++) {
$string .= 'a';
}
# The pattern matches for \\, \", everything except " and "
$pattern = '/^(\\\\|\\"|[^"]|")+$/';
print "Trying with string length " . "\033" . '[s';
for ($counter=6600; $counter<strlen($string); $counter++) {
if (preg_match($pattern, substr($string,0,$counter), $matches)) {
print "\033" . '[u' . $counter . '...';
flush();
list($dummy, $aa) = $matches;
}
}
print "\n";
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/47811
--
Edit this bug report at http://bugs.php.net/?id=47811&edit=1