#36463 [Com]: preg_match crashes

From: Date: Wed, 20 Jan 2010 23:08:13 +0000
Subject: #36463 [Com]: preg_match crashes
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-146835@lists.php.net to get a copy of this message
 ID:               36463
 Comment by:       liviu dot mirea at gmail dot com
 Reported By:      sthapa at site5 dot com
 Status:           Feedback
 Bug Type:         PCRE related
 Operating System: Linux
 PHP Version:      5.1.2
 New Comment:

On CentOS 5.4, PHP 5.3.1, Apache/2.2.3:

With "$count = 5947;" it works. With "$count = 5948;" or higher it
silently crashes. Apache error log: "[Thu Jan 21 01:02:15 2010] [notice]
child pid 18136 exit signal Segmentation fault (11)"

rasmus at php at net, try giving it larger values.


Previous Comments:
------------------------------------------------------------------------

[2010-01-20 22:47:52] rasmus@php.net

Works fine on Linux

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

[2010-01-20 22:44:30] liviu dot mirea at gmail dot com

I tested it again and it crashed on my current configuration: PHP
5.3.1, Apache/2.2.14 (Win32), Windows 7 (64 bit)

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

[2010-01-19 16:06:51] pajoye@php.net

Which web server? Apache?

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

[2010-01-19 16:02:06] stijn_koopal at hotmail dot com

Same problem with code of liviu dot mirea at gmail dot com.
OS: Windows 7 (32 bit)
PHP: 5.3.1

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

[2009-08-15 12:56:11] liviu dot mirea at gmail dot com

I have the same problem. Simply try the following simpler test case:

$count = 500;
$string = str_repeat("a", $count);
echo preg_match('/\A(
	     [\x09\x0A\x0D\x20-\x7E]
	   | [\xC2-\xDF][\x80-\xBF]
	   |  \xE0[\xA0-\xBF][\x80-\xBF]
	   | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}
	   |  \xED[\x80-\x9F][\x80-\xBF]
	   |  \xF0[\x90-\xBF][\x80-\xBF]{2}
	   | [\xF1-\xF3][\x80-\xBF]{3}
	   |  \xF4[\x80-\x8F][\x80-\xBF]{2}
	  )*\z/x', $string);

If is doesn't crash, try increasing the $count variable.
This bug seems to be related (if not the same) with
http://bugs.php.net/bug.php?id=27070

I'm sorry but I can't believe this bug has been around for 5 years.

Tested on PHP 5.3.0 and Windows 7 64bits

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

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/36463

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



Thread (15 messages)

« previous php.bugs (#146835) next »