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

From: Date: Mon, 24 Mar 2014 09:50:10 +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-184863@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=54275&edit=1

 ID:                 54275
 Comment by:         nicolas dot grekas+php at gmail dot com
 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:

Looks like this bug has been fixed in 5.5:
http://3v4l.org/JMsFv


Previous Comments:
------------------------------------------------------------------------
[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)

« previous php.bugs (#184863) next »