Bug #69640 [Asn->Csd]: Unhandled EngineExceptions thrown from userland do not produce any output
| From: | laruence@php.net | Date: | Mon, 18 May 2015 03:04:05 +0000 |
| Subject: | Bug #69640 [Asn->Csd]: Unhandled EngineExceptions thrown from userland do not produce any output | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-192724@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=69640&edit=1
ID: 69640
Updated by: laruence@php.net
Reported by: contact at jubianchi dot fr
Summary: Unhandled EngineExceptions thrown from userland do
not produce any output
-Status: Assigned
+Status: Closed
Type: Bug
Package: *General Issues
PHP Version: master-Git-2015-05-15 (Git)
Assigned To: laruence
Block user comment: N
Private report: N
New Comment:
The fix for this bug has been committed.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
For Windows:
http://windows.php.net/snapshots/
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2015-05-15 18:32:54] rdlowrey@php.net
Actually my previous comment is unrelated to the
EngineException issue. The memory leak
only occurs with an uncaught exception. Please disregard the above.
------------------------------------------------------------------------
[2015-05-15 17:55:05] rdlowrey@php.net
There seems to be a leak in the latest master as well which is visible using a debug build:
[daniel@centos aerys]$ php7 -a
Interactive shell
php > $test = new TypeException("test");
php > throw new \RuntimeException;
Warning: Uncaught exception 'RuntimeException' in php shell code:1
Stack trace:
#0 {main}
thrown in php shell code on line 1
php > exit
[Fri May 15 13:48:52 2015] Script: '-'
/home/daniel/dev/c/php-src/Zend/zend_objects.c(145) : Freeing 0xB7464280 (136 bytes), script=-
=== Total 1 memory leaks detected ===
------------------------------------------------------------------------
[2015-05-15 14:51:13] contact at jubianchi dot fr
> maybe we should disallow initialize a engineException/ParserExcetpion etc in userland?
I think EngineException/ParserExcetpion should not be allowed in userland code. When they are used
they can produce too much side effects, i.e a user exception handled as if it were an actual
catchable fatal error.
------------------------------------------------------------------------
[2015-05-15 14:25:14] laruence@php.net
maybe we should disallow initialize a engineException/ParserExcetpion etc in userland?
Anyway, a quick fix is set type if it is zero:
/* This function doesn't return if it uses E_ERROR */
ZEND_API void zend_exception_error(zend_object *ex, int severity) /* {{{ */
@@ -914,6 +914,10 @@ ZEND_API void zend_exception_error(zend_object *ex, int severity) /* {{{ */
zend_long line = zval_get_long(GET_PROPERTY_SILENT(&exception, "line"));
zend_long code = zval_get_long(GET_PROPERTY_SILENT(&exception, "code"));
+ if (UNEXPECTED(code == 0)) {
+ code = E_ERROR;
+ }
+
if (ce_exception == type_exception_ce && strstr(message->val, ", called in
")) {
zend_error_helper(code, file->val, line, "%s and defined", message->val);
} else {
------------------------------------------------------------------------
[2015-05-15 13:53:04] contact at jubianchi dot fr
Description:
------------
Today, I was playing with EngineException when I saw something that might be a bug.
EngineException are throwable from userland but if we do so, and do not handle the exception, PHP
exits with a status 254 and produces no output.
Test script:
---------------
<?php
// http://3v4l.org/sLnOI
throw new \EngineException('I mess everything up! :trollface:');
Expected result:
----------------
Fatal error: Uncaught exception 'EngineException' with message 'I mess everything up!
:trollface:' in /in/3TbdX:5
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=69640&edit=1