php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #40770 Apache child exits when PHP memory limit reached
Submitted: 2007-03-10 03:24 UTC Modified: 2007-03-12 17:00 UTC
From: php at edwardk dot info Assigned: dmitry (profile)
Status: Closed Package: Reproducible crash
PHP Version: 5.2.1 OS: Windows 2003
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: php at edwardk dot info
New email:
PHP Version: OS:

 

 [2007-03-10 03:24 UTC] php at edwardk dot info
Description:
------------
Running Apache 1.3.37 with PHP 5.2.1 on Windows 2003 Standard 32bit

The following PHP code was called from a browser with the size=149 (to simulate 149MB use) and the PHP memory limit is 160M.


Reproduce code:
---------------
<?
ini_set('display_errors',true);
if (isset($_GET['size']) && $_GET['size'] < 200) {
$mb = intval($_GET['size']);
}
else {
	$mb=5;
}
$var = '';
echo 'Memory limit: '.ini_get('memory_limit').'<br>';
for ($i=0; $i<=$mb; $i++) {
        $var.= str_repeat('a',1*1024*1024);
        echo memory_get_usage().'<br>';
}
echo 'String length: '. strlen($var);
?>

Expected result:
----------------
PHP should, if it did run out of memory, exit with something along the lines of

Fatal error:  Allowed memory size of xxx bytes exhausted (tried to allocate yyy bytes)

otherwise, the script should execute without crashing.

Actual result:
--------------
Apache child exits, browser waiting for the result of the page get a TCP connection reset and no page loaded.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-03-11 14:52 UTC] iliaa@php.net
Are you running debug build of PHP by any chance?
 [2007-03-11 21:35 UTC] php at edwardk dot info
I don't believe so. It should be the official PHP 5.2.1 windows binary release.

phpinfo() reports:


PHP Version 5.2.1
Build Date 	Feb 7 2007 23:10:31
Configure Command 	cscript /nologo configure.js "--enable-snapshot-build" "--with-gd=shared"
 [2007-03-12 03:27 UTC] edink@php.net
I can reproduce the problem. When running this example in CLI PHP aborts with:

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 133169153 bytes) in C:\php4build\PHP_5_2\Release_TS\t.php on line 12
zend_mm_heap corrupted

 [2007-03-12 03:36 UTC] edink@php.net
Also happens in the latest 5.2 with both win32 and malloc ZEND_MM_MEM_TYPE.

USE_ZEND_ALLOC=0 makes the problem disappear, but then no memory limit is enforced.

 [2007-03-12 17:00 UTC] dmitry@php.net
Fixed in CVS HEAD and PHP_5_2
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 15:01:30 2024 UTC