Bug #54317 [Opn->Nab]: Regexp crashes Apache/PHP
| From: | cmb@php.net | Date: | Sat, 20 Aug 2016 12:11:50 +0000 |
| Subject: | Bug #54317 [Opn->Nab]: Regexp crashes Apache/PHP | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-203413@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=54317&edit=1
ID: 54317
Updated by: cmb@php.net
Reported by: christian dot achatz at adventure-php-framework
Summary: Regexp crashes Apache/PHP
-Status: Open
+Status: Not a bug
Type: Bug
Package: PCRE related
Operating System: Windows
PHP Version: 5.3.6
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
The potential stack exhaustion is alread noted in the manual, see
<http://php.net/manual/en/pcre.configuration.php#ini.pcre.recursion-limit>.
More detailed information might quickly become out-dated.
Previous Comments:
------------------------------------------------------------------------
[2011-03-25 10:22:33] christian dot achatz at adventure-php-framework
Thanks for your analysis. I'll try the solution described on the MSDN article.
------------------------------------------------------------------------
[2011-03-19 17:56:35] pajoye@php.net
Maybe worth adding my last comment to the PHP manual.
------------------------------------------------------------------------
[2011-03-19 17:56:09] pajoye@php.net
Stack size problem. You can run the script through the CLI sapi to see that PHP
actually works. However Apache has a smaller stack and causes such regexp to crash
(or similar side effect). Increase the stack of Apache to fix this problem. Use
Editbin for that: http://msdn.microsoft.com/en-us/library/d25ddyfc(v=VS.80).aspx
------------------------------------------------------------------------
[2011-03-19 16:05:27] christian dot achatz at adventure-php-framework
Description:
------------
---
From manual page: http://www.php.net/function.preg-replace#Description
---
Calling the script below apache crashes on windows installations. After removing almost any of the
lines inside $notworking apache will NOT crash, no matter which line was removed in most cases.
Here is the system list that causes a crash or not:
Windows 7 SP1 (64bit) | XAMPP | Apache/2.2.17 (Win32) | PHP 5.3.5 | <<<<<<<
CRASH!
Windows XP (32+64bit) | XAMPP | Apache 2.2.17 | PHP 5.3.5 | <<<<<<< CRASH!
WinXP 32Bit / Apache 2.2.17 / PHP 5.2.14 <<<<<<< CRASH!
Fedora 32Bit / Apache 2.2.15 / PHP 5.3.3 --> OK
Ubuntu 10.10 32Bit / Apache2 2.2.16 / PHP 5.3.3 -> OK
Test script:
---------------
<?php
echo 'Is the following crashing apache or whatever?<br />'.PHP_EOL;
// After removing almost any of the lines inside $notworking apache will NOT crash, no matter which
line was removed in most cases.
$notworking = '<?php
//<*IslandStorageBase:start*> DO NOT CHANGE THIS COMMENT!
/**
* Automatically generated BaseObject for IslandStorage. !!DO NOT CHANGE THIS BASE-CLASS!!
* CHANGES WILL BE OVERWRITTEN WHEN UPDATING!!
* You can change class "IslandStorage" which will extend this base-class.
*/
class IslandStorageBase extends AbstractSimpleStorage {
}
<*IslandStorageBase:end*>
?>';
$content = preg_replace(
'%//<\*IslandStorageBase:start\*>(.)+<\*IslandStorageBase:end\*>%s',
'test',
$notworking
);
echo 'If you can see this everything seems to be working fine.';
?>
Expected result:
----------------
Is the following crashing apache or whatever?
If you can see this everything seems to be working fine.
Actual result:
--------------
Apache crashes with the following log entry:
Parent: child process exited with status xyz -- Restarting.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=54317&edit=1