Bug #54275 [Opn->Csd]: Exception thrown in error_handler is swallowed
Edit report at https://bugs.php.net/bug.php?id=54275&edit=1
ID: 54275
Updated by: danack@php.net
Reported by: v-o-e at gmx dot de
Summary: Exception thrown in error_handler is swallowed
-Status: Open
+Status: Closed
Type: Bug
Package: Scripting Engine problem
Operating System: all
PHP Version: 5.3.5
-Assigned To:
+Assigned To: danack
Block user comment: N
Private report: N
New Comment:
This was apparently fixed for PHP 5.5.
Previous Comments:
------------------------------------------------------------------------
[2014-03-24 09:50:09] nicolas dot grekas+php at gmail dot com
Looks like this bug has been fixed in 5.5:
http://3v4l.org/JMsFv
------------------------------------------------------------------------
[2011-03-17 11:18:05] mplomer at gmx dot de
I just downtracked the same problem. Additionally I have noticed that after the fatal error occours
(after throwing the notice, which is swallowed), the shutdownFunction isn't called at all
(tested on PHP 5.3.2).
When not throwing an error in error-handler, shutdownFunction is called properly.
------------------------------------------------------------------------
[2011-03-16 16:23:35] v-o-e at gmx dot de
Description:
------------
Exception thrown in error_handler is swallowed if fatal error occurs after error in same instruction
somewhat related (closed) bugs:
http://bugs.php.net/bug.php?id=36773
http://bugs.php.net/bug.php?id=51463
Test script:
---------------
function error($code, $message, $file = null, $line = 0) {
echo "convert error to exception<br>\n";
throw new \ErrorException($message, $code, null, $file, $line);
}
function shutdown() {
echo "shutdown function called<br>\n";
}
set_error_handler('error');
register_shutdown_function('shutdown');
try {
echo $crypto->compress();
} catch (\Exception $e) {
echo "exception catched<br>\n";
}
echo "after fatal error<br>\n";
Expected result:
----------------
exception should be catched as in (note the @ operator to suppress a FATAL ERROR!):
function error($code, $message, $file = null, $line = 0) {
echo "convert error to exception<br>\n";
throw new \ErrorException($message, $code, null, $file, $line);
}
function shutdown() {
echo "shutdown function called<br>\n";
}
set_error_handler('error');
register_shutdown_function('shutdown');
try {
echo @$crypto->compress();
} catch (\Exception $e) {
echo "exception catched<br>\n";
}
echo "after fatal error<br>\n";
Actual result:
--------------
1. Exception thrown in error_handler is swallowed
2. the "fatal error" after "Undefined variable" occurs
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=54275&edit=1
Thread (4 messages)