Bug #54275 [Com]: Exception thrown in error_handler is swallowed

From: Date: Thu, 17 Mar 2011 10:18:06 +0000
Subject: Bug #54275 [Com]: Exception thrown in error_handler is swallowed
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-159548@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=54275&edit=1

 ID:                 54275
 Comment by:         mplomer at gmx dot de
 Reported by:        v-o-e at gmx dot de
 Summary:            Exception thrown in error_handler is swallowed
 Status:             Open
 Type:               Bug
 Package:            Scripting Engine problem
 Operating System:   all
 PHP Version:        5.3.5
 Block user comment: N
 Private report:     N

 New Comment:

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.


Previous Comments:
------------------------------------------------------------------------
[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 http://bugs.php.net/bug.php?id=54275&edit=1


Thread (4 messages)

« previous php.bugs (#159548) next »