|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2002-12-03 16:12 UTC] busia at tiscali dot it
I have a php installation with a memory limit set to 8MB. If I try to run this script
<?
for ($i=0; $i<=10000000; $i++) {
$var.="a";
}
echo "all is ok";
?>
I don't receive an error like "memory limit excedeed" (10MB > 8MB), simply the server kills the connection without any error on the screen or in the logs.
Server configuration:
Linux Redhat 7.0
Apache 1.3.22
PHP 4.3.0RC2
Zend Optimizer 2.0.3
Mysql 4.0.5
Configure:
'./configure' '--enable-track-vars' '--prefix=/usr' '--exec-prefix=/usr'
'--libexecdir=/usr/lib/apache' '--bindir=/usr/bin' '--sbindir=/usr/sbin'
'--datadir=/home/httpd' '--sysconfdir=/etc/httpd/conf'
'--localstatedir=/var' '--libdir=/usr/lib/apache'
'--includedir=/usr/include/apache' '--mandir=/usr/man' '--with-mysql=/usr'
'--enable-memory-limit' '--with-config-file-path=/usr/local/Zend/etc'
'--with-apxs' '--with-zlib'
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 11:00:01 2025 UTC |
I can also verify this with 4.3.0-cvs. With the cli PHP I can get a core dump showing a nearly endless calling stack - probably the memory_limit only looks at the data size, not at the stack size (but of course this huge stack usage should not happen in the first place). #0 0x081d0c26 in php_error_cb () (gdb) bt -30 #29239 0x081d0c4d in php_error_cb () #29240 0x08209b38 in zend_error () #29241 0x081f5d03 in _emalloc () #29242 0x081f5fc1 in _erealloc () #29243 0x081d4154 in xbuf_resize () #29244 0x081d41ec in xbuf_init () #29245 0x081d4f4a in vspprintf () #29246 0x081d0c4d in php_error_cb () #29247 0x08209b38 in zend_error () #29248 0x081f5d03 in _emalloc () #29249 0x081f5fc1 in _erealloc () #29250 0x081d4154 in xbuf_resize () #29251 0x081d41ec in xbuf_init () #29252 0x081d4f4a in vspprintf () #29253 0x081d0c4d in php_error_cb () #29254 0x08209b38 in zend_error () #29255 0x081f5d03 in _emalloc () #29256 0x081f5fc1 in _erealloc () #29257 0x081d4154 in xbuf_resize () #29258 0x081d41ec in xbuf_init () #29259 0x081d4f4a in vspprintf () #29260 0x081d0c4d in php_error_cb () #29261 0x08209b38 in zend_error () #29262 0x081f61fe in _erealloc () #29263 0x08205ab5 in concat_function () #29264 0x08218c48 in execute () #29265 0x08209fa4 in zend_execute_scripts () #29266 0x081d32dc in php_execute_script () #29267 0x08221707 in main () #29268 0x402718c1 in __libc_start_main (main=0x8220b48 <main>, argc=3, argv=0xbfffe944, init=0x80792f8 <_init>, fini=0x826c8f4 <_fini>, rtld_fini=0x4000a914 <_dl_fini>, stack_end=0xbfffe93c) at ../sysdeps/generic/libc-start.c:92I have reproduced this issue with the released 4.3.0. When the memory limit is exceeded, the program dies without the slitest indication as to why. The exact same test with PHP 4.2.3 prints an error: "PHP Fatal error: Allowed memory size of 10485760 bytes exhausted (tried to allocate 1 bytes) in - on line 1". The following command line is what I used to produce the message above: echo -n '<?php $s = ""; for ($i = 0; $i < 10000000000; $i++) {$s .= " ";} print("finished"); ?>' | php -q