Bug #77575 [NEW]: set_error_handler() / ErrorException memory leak
From: frame86 at live dot com
Operating system: Ubuntu 18.04.1 LTS
PHP version: 7.2.14
Package: *General Issues
Bug Type: Bug
Bug description:set_error_handler() / ErrorException memory leak
Description:
------------
Using an error handler, throwing and catching the ErrorException leaks
memory.
Test script:
---------------
<?php
$last = time();
ini_set('memory_limit', '8G');
set_error_handler(function ($severity, $message, $file, $line) {
throw new \ErrorException($message, 0, $severity, $file, $line);
});
while(true)
{
try {
trigger_error("Something");
} catch(\Throwable $e) {
}
if(time() - $last >= 1) {
$last = time();
printf("\nMemory: %.4f", memory_get_usage() / (1024 * 1024));
}
gc_collect_cycles(); // doesn't help much
}
Expected result:
----------------
Nearly constant memory usage
Actual result:
--------------
Memory: 3.7187
Memory: 5.0504
Memory: 6.0593
Memory: 6.9050
Memory: 7.6437
Memory: 8.3095
Memory: 8.9218
Memory: 9.4904
...
Memory: 97.7963
Memory: 219.5202
Memory: 300.1706
Segmentation fault (core dumped)
--
Edit bug report at https://bugs.php.net/bug.php?id=77575&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=77575&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=77575&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=77575&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=77575&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=77575&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=77575&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=77575&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=77575&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=77575&r=support
Expected behavior: https://bugs.php.net/fix.php?id=77575&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=77575&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=77575&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=77575&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=77575&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=77575&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=77575&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=77575&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=77575&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=77575&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=77575&r=mysqlcfg
Thread (2 messages)
- frame86 at live dot com