Bug #54275 [NEW]: Exception thrown in error_handler is swallowed
| From: | v-o-e at gmx dot de | Date: | Wed, 16 Mar 2011 15:23:38 +0000 |
| Subject: | Bug #54275 [NEW]: Exception thrown in error_handler is swallowed | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-159523@lists.php.net to get a copy of this message | ||
From:
Operating system: all
PHP version: 5.3.5
Package: Scripting Engine problem
Bug Type: Bug
Bug description:Exception thrown in error_handler is swallowed
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 bug report at http://bugs.php.net/bug.php?id=54275&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=54275&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=54275&r=trysnapshot53
Try a snapshot (trunk): http://bugs.php.net/fix.php?id=54275&r=trysnapshottrunk
Fixed in SVN: http://bugs.php.net/fix.php?id=54275&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=54275&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=54275&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=54275&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=54275&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=54275&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=54275&r=support
Expected behavior: http://bugs.php.net/fix.php?id=54275&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=54275&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=54275&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=54275&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=54275&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=54275&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=54275&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=54275&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=54275&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=54275&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=54275&r=mysqlcfg