#34156 [NEW]: memory_limit doesn't prevent exit

From: Date: Tue, 16 Aug 2005 18:58:24 +0000
Subject: #34156 [NEW]: memory_limit doesn't prevent exit
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-83655@lists.php.net to get a copy of this message
From: robert at rw-it dot net Operating system: Win32 PHP version: 4.4.0 PHP Bug Type: Reproducible crash Bug description: memory_limit doesn't prevent exit Description: ------------ If memory_limit is turned on, memory will be marked as allocated although it isn't, because the _CHECK_MEMORY_LIMIT macro (zend_alloc.c) starts like this: #define _CHECK_MEMORY_LIMIT(s, rs, file, lineno) { AG(allocated_memory) += rs;\ Thus, allocated_memory is increased by the block size, even though zend_error might be called. This seems to apply to PHP-5.0.4, too, but not tested (only looked at the code). Reproduce code: --------------- Write some script that consumes all available memory: for ($i = 0, $b = 'x'; ; $i++, $b .= $b) echo "$i, "; Reload a few times. Expected result: ---------------- Same output everytime, no exit(1). Output for memory_limit = 8M on my machine: Allowed memory size of 8388608 bytes exhausted (tried to allocate 4194305 bytes) Actual result: -------------- Available memory decreases with each reload, until finally AG(memory_limit)+1048576 < AG(allocated_memory) - rs and PHP exits. Output for memory_limit = 8M: Allowed memory size of 8388608 bytes exhausted (tried to allocate 4194305 bytes) Allowed memory size of 8388608 bytes exhausted (tried to allocate 2097153 bytes) ... Allowed memory size of 8388608 bytes exhausted (tried to allocate 2049 bytes) (Server process exits on next reload) -- Edit bug report at http://bugs.php.net/?id=34156&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=34156&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=34156&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=34156&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=34156&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=34156&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=34156&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=34156&r=needscript Try newer version: http://bugs.php.net/fix.php?id=34156&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=34156&r=support Expected behavior: http://bugs.php.net/fix.php?id=34156&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=34156&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=34156&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=34156&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=34156&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=34156&r=dst IIS Stability: http://bugs.php.net/fix.php?id=34156&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=34156&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=34156&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=34156&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=34156&r=mysqlcfg

« previous php.bugs (#83655) next »