From:
Operating system: Ubuntu 10.04
PHP version: 5.3.7
Package: PCRE related
Bug Type: Bug
Bug description:preg_match segmentation fault when subject too large
Description:
------------
When I change $n_times to 80000, and run the command line script php -f
myscript.php, I get "Segmentation Fault". The error also occurs when run
via apache: [Fri Aug 19 15:05:14 2011] [notice] child pid 11995 exit signal
Segmentation fault (11)
If you change $n_times to be sufficiently large, preg_match seems to
consistently seg fault.
If I change $n_times to something lower like 1000, there is no seg fault.
Test script:
---------------
<?php
$n_times = 80000;
$string = str_repeat('a',$n_times);
//regex from: http://w3.org/International/questions/qa-forms-utf-8.html
echo preg_match('%^(?:
[\x09\x0A\x0D\x20-\x7E] # ASCII
| [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte
| \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs
| [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte
| \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates
| \xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3
| [\xF1-\xF3][\x80-\xBF]{3} # planes 4-15
| \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16
)*$%xs', $string) ? 'y' : 'n';
die("\n");
Expected result:
----------------
'y' or 'n'
Actual result:
--------------
command line:
Segmentation Fault
via apache error.log
[Fri Aug 19 15:05:14 2011] [notice] child pid 11995 exit signal
Segmentation fault (11)
--
Edit bug report at https://bugs.php.net/bug.php?id=55465&edit=1
--
Try a snapshot (PHP 5.4):
https://bugs.php.net/fix.php?id=55465&r=trysnapshot54
Try a snapshot (PHP 5.3):
https://bugs.php.net/fix.php?id=55465&r=trysnapshot53
Try a snapshot (trunk):
https://bugs.php.net/fix.php?id=55465&r=trysnapshottrunk
Fixed in SVN:
https://bugs.php.net/fix.php?id=55465&r=fixed
Fixed in SVN and need be documented:
https://bugs.php.net/fix.php?id=55465&r=needdocs
Fixed in release:
https://bugs.php.net/fix.php?id=55465&r=alreadyfixed
Need backtrace:
https://bugs.php.net/fix.php?id=55465&r=needtrace
Need Reproduce Script:
https://bugs.php.net/fix.php?id=55465&r=needscript
Try newer version:
https://bugs.php.net/fix.php?id=55465&r=oldversion
Not developer issue:
https://bugs.php.net/fix.php?id=55465&r=support
Expected behavior:
https://bugs.php.net/fix.php?id=55465&r=notwrong
Not enough info:
https://bugs.php.net/fix.php?id=55465&r=notenoughinfo
Submitted twice:
https://bugs.php.net/fix.php?id=55465&r=submittedtwice
register_globals:
https://bugs.php.net/fix.php?id=55465&r=globals
PHP 4 support discontinued:
https://bugs.php.net/fix.php?id=55465&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=55465&r=dst
IIS Stability:
https://bugs.php.net/fix.php?id=55465&r=isapi
Install GNU Sed:
https://bugs.php.net/fix.php?id=55465&r=gnused
Floating point limitations:
https://bugs.php.net/fix.php?id=55465&r=float
No Zend Extensions:
https://bugs.php.net/fix.php?id=55465&r=nozend
MySQL Configuration Error:
https://bugs.php.net/fix.php?id=55465&r=mysqlcfg