From: csaba at alum dot mit dot edu Operating system: Win XP PHP version: 5CVS-2007-01-25 (snap) PHP Bug Type: Scripting Engine problem Bug description: echo ... | php -a function allocation eats memory
Description: ------------ The following command line (single line in the cmd window) call does not work unless memory_limit is set to 9M or higher in php.ini on my Win XP Pro: echo ^^^<?php $p='function f';$s='(){}'; for($i=0;++$i^^^<7;) eval($p.$i.$s); print('success'); ?^^^> | php.exe -a It complains about having run out of memory: Interactive mode enabled Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 786432 bytes) in C:\phpLib\-(1) : eval()'d code on line 1 Reproduce code: --------------- <?php // name this file test.php function func1() { } function func2() { } function func3() { } function func4() { } function func5() { } function func6() { } function func7() { } print ('success'); ?> The invocation line above looks a little scary (but it's just a loop to define functions) - the below single line achieves the same result: echo ^^^<?php include('test.php'); ?^^^> | php -a Expected result: ---------------- I expect the default configuration (of 8M) to be more than enough for trivial code to be invoked with the -a option. Indeed, php.exe -r "include(test.php);" works just fine It seems like each function declaration gobbles over 1M of memory when php is invoked with the -a option. I use the -a construct frequently since php-cgi.exe does not allow the -r construct, and I've noticed that between July and December of 2006 is when this problem started happening. In particular, I have an auto_prepend_file with about 50 functions defined and for php to start running on this requires that I set memory_limit to 56M minimum so that the php invocations with -a can run! Actual result: -------------- Tested on the most recent snaps of PHP 5.2 and PHP 6. Csaba Gabor from Vienna -- Edit bug report at http://bugs.php.net/?id=40236&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=40236&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=40236&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=40236&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=40236&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=40236&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=40236&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=40236&r=needscript Try newer version: http://bugs.php.net/fix.php?id=40236&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=40236&r=support Expected behavior: http://bugs.php.net/fix.php?id=40236&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=40236&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=40236&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=40236&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=40236&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=40236&r=dst IIS Stability: http://bugs.php.net/fix.php?id=40236&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=40236&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=40236&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=40236&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=40236&r=mysqlcfg