]> granicus.if.org Git - php/commitdiff
Fixed bug #40770 (Apache child exits when PHP memory limit reached)
authorDmitry Stogov <dmitry@php.net>
Mon, 12 Mar 2007 17:00:07 +0000 (17:00 +0000)
committerDmitry Stogov <dmitry@php.net>
Mon, 12 Mar 2007 17:00:07 +0000 (17:00 +0000)
Zend/tests/bug40770.phpt [new file with mode: 0755]
Zend/zend_alloc.c

diff --git a/Zend/tests/bug40770.phpt b/Zend/tests/bug40770.phpt
new file mode 100755 (executable)
index 0000000..fd01303
--- /dev/null
@@ -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
index edc39166f3c47cfe25c62cdbb84a8f63a4a09c94..03914cc62952d2f8be486fda11d1edc17966fc5c 100644 (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