#45735 [Ver->Fbk]: preg_match fails with Segmentation Fault on capturing subpattern

From: Date: Wed, 06 Aug 2008 16:38:30 +0000
Subject: #45735 [Ver->Fbk]: preg_match fails with Segmentation Fault on capturing subpattern
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-127680@lists.php.net to get a copy of this message
 ID:               45735
 Updated by:       jani@php.net
 Reported By:      johnston dot joshua at gmail dot com
-Status:           Verified
+Status:           Feedback
 Bug Type:         PCRE related
 Operating System: *
 PHP Version:      5.2CVS, 5.3CVS, 6CVS (2008-08-06)
 New Comment:

Setting pcre.backtrack_limit = 10000 prevents the crash for me.



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

[2008-08-06 16:36:27] jani@php.net

==18470== Stack overflow in thread 1: can't grow stack to 0x7FE601FA8
==18470==
==18470== Process terminating with default action of signal 11
(SIGSEGV)
==18470==  Access not within mapped region at address 0x7FE601FA8
==18470==    at 0x4358C0: match (pcre_exec.c:403)
==18470== Stack overflow in thread 1: can't grow stack to 0x7FE601EC8


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

[2008-08-06 15:22:20] johnston dot joshua at gmail dot com

Description:
------------
When running a preg_match with a capturing subpattern against large
input, php crashes with a Segmentation Fault
I tested this on OS X and OpenSuSE, same result
OS X:~$ php -v
PHP 5.2.6 (cli) (built: Jul 15 2008 12:18:21) 

OpenSuSE:~# php -v
PHP 4.4.7 (cgi) (built: May 12 2008 10:19:51)

Reproduce code:
---------------
<?php
preg_match("/http:\/\/(.)+\.ru/i", str_repeat("http://google.ru",
2000));
?>

Expected result:
----------------
PHP should handle the error or something other than letting PCRE crash
php

Actual result:
--------------
jjohnston:~$ php -r 'preg_match("/http:\/\/(.)+\.ru/i",
str_repeat("http://google.ru", 2000));'
Segmentation fault


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


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



Thread (18 messages)

« previous php.bugs (#127680) next »