Re: [RFC] Exceptions in the engine
| From: | Nikita Popov | Date: | Thu, 24 Oct 2013 20:16:27 +0000 |
| Subject: | Re: [RFC] Exceptions in the engine | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-69856@lists.php.net to get a copy of this message | ||
On Thu, Oct 24, 2013 at 9:57 PM, Stas Malyshev <smalyshev@sugarcrm.com>wrote:
> Hi!
>
> Looking at the patch, it converts zend_error_noreturn into
> ZEND_IMPOSSIBLE, which is nothing in non-debug mode. This means code
> that expected that execution ceases it this point (and jumps to a safe
> bail-out point) now just continues in non-debug mode (probably causing
> crash or memory corruption) or exits the process on failed assert in
> debug mode. I'm not sure it is a good idea to do this.
To make sure that there are no misunderstandings, Stas is referring to two
particular occurrences where E_ERROR has been replaced with a
ZEND_IMPOSSIBLE macro. Both occurrences are unreachable code (or so I
judged), so they are effectively assertions implemented using E_ERROR
rather than assert(). The ZEND_IMPOSSIBLE macro is a more explicit way of
saying assert(0). PHP removes assertions in non-debug builds
(optimization), so this follows suit.
I did not mention this in the RFC because I'm not yet sure this change is
necessary and I might yet keep them as (pointless) fatal errors instead,
just in case. This is mainly a note to myself that I looked at the error
and decided that it does not require conversion.
> A lot of code assumes execution does not proceed past E_ERROR, but
exceptions do not work that way.
>
That's correct. In the places where I replaced fatal errors with exceptions
I make sure to free resources and handle the exception.
Nikita