From:             ceo at l-i-e dot com
Operating system: FreeBSD 4.10-STABLE
PHP version:      4.3.10
PHP Bug Type:     *Programming Data Structures
Bug description:  Memory Limit bypasses set_error_handler

Description:
------------
set_error_handle seems totally ineffective for Memory Limit settings.


Reproduce code:
---------------
ini_set('memory_limit', '32K');
ini_set('error_reporting', 0);
echo "Memory Limit: ", ini_get('memory_limit'), "\n";
echo "Memory Used: ", memory_get_usage(), "\n";
function error_handler($error, $message, $file, $line){
  echo "Error ($error) in $file:$line - $message\n";
  return true;
}

set_error_handler('error_handler');
trigger_error("Test", E_USER_NOTICE);

$str = str_repeat('a', 1024);
while (true){
  echo '.';
  flush();
  $str .= $str;
}
echo "\nMade it!\n";


Expected result:
----------------
I expected to see the same error message PHP usually reports, more or
less, and then "Made it!".


Actual result:
--------------
-bash-2.05b$ php test.php 
Content-type: text/html
X-Powered-By: PHP/4.3.10

Memory Limit: 32K
Memory Used: 13432
Error (1024) in /www/l-i-e.com/web/test.php:12 - Test
....-bash-2.05b$ 

Note that my test error message comes out, and PHP continues, but upon
reaching memory limit, it just dies, with no call to my error handler.
:-(

I'm not sure that a soft limit imposed should necessarily be considered
non-recoverable...

Though I can see how even trying to call the function at that point is
problematic, in terms of not triggering the error again in an infinite
loop...

Still, it would be nice to be able to trap this and do something useful
rather than just die, if possible.


-- 
Edit bug report at http://bugs.php.net/?id=31905&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=31905&r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=31905&r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=31905&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=31905&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=31905&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=31905&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=31905&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=31905&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=31905&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=31905&r=notwrong
Not enough info:             
http://bugs.php.net/fix.php?id=31905&r=notenoughinfo
Submitted twice:             
http://bugs.php.net/fix.php?id=31905&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=31905&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=31905&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=31905&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=31905&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=31905&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=31905&r=float
No Zend Extensions:          http://bugs.php.net/fix.php?id=31905&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=31905&r=mysqlcfg

Reply via email to