1
0
mirror of https://github.com/php/php-src.git synced 2026-04-18 13:31:27 +02:00

Fixed bug #40770 (Apache child exits when PHP memory limit reached)

This commit is contained in:
Dmitry Stogov
2007-03-12 17:00:07 +00:00
parent 43c8316d2d
commit 5a4f3bcd37
2 changed files with 18 additions and 0 deletions

15
Zend/tests/bug40770.phpt Executable file
View File

@@ -0,0 +1,15 @@
--TEST--
Bug #40770 Apache child exits when PHP memory limit reached
--INI--
memory_limit=64M
--FILE--
<?php
ini_set('display_errors',true);
$mb=148;
$var = '';
for ($i=0; $i<=$mb; $i++) {
$var.= str_repeat('a',1*1024*1024);
}
?>
--EXPECTF--
Fatal error: Allowed memory size of 67108864 bytes exhausted%s(tried to allocate %d bytes) in %sbug40770.php on line 6

View File

@@ -1711,6 +1711,9 @@ realloc_segment:
segment_copy = (zend_mm_segment *) ((char *)mm_block - ZEND_MM_ALIGNED_SEGMENT_SIZE);
if (segment_size < true_size ||
heap->real_size + segment_size - segment_copy->size > heap->limit) {
if (ZEND_MM_IS_FREE_BLOCK(next_block)) {
zend_mm_add_to_free_list(heap, (zend_mm_free_block *) next_block);
}
#if ZEND_MM_CACHE
zend_mm_free_cache(heap);
#endif