Edit report at http://bugs.php.net/bug.php?id=54317&edit=1
ID: 54317
Comment by: christian dot achatz at adventure-php-framework dot
org
Reported by: christian dot achatz at adventure-php-framework
Summary: Regexp crashes Apache/PHP
Status: To be documented
Type: Bug
Package: Regexps related
Operating System: Windows
PHP Version: 5.3.6
Block user comment: N
Private report: N
New Comment:
Thanks for your analysis. I'll try the solution described on the MSDN
article.
Previous Comments:
------------------------------------------------------------------------
[2011-03-19 17:56:35] [email protected]
Maybe worth adding my last comment to the PHP manual.
------------------------------------------------------------------------
[2011-03-19 17:56:09] [email protected]
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 http://bugs.php.net/bug.php?id=54317&edit=1