This is an old revision of the document!

PHP RFC: Recoverably fatal exceptions in undeterministic contexts


Exceptions thrown from undeterministic contexts, like destructors, signal handlers, tick handlers etc. shouldn't throw exceptions into the scope from which they were called.

That may lead to weird behavior, like unexpected types of exceptions. (For example a catch all handler for one specific task receives an exception thrown from a destructor due to garbage collection occurring. It will handle the error in an inappropriate way.)


Make uncaught exceptions, thrown from functions called from these undeterministic contexts, call the exception handler, and, if not handled, throw an E_RECOVERABLE_ERROR.

As undeterministic context counts everything which is not explicitly or implicitly called by direct use of an operator or function. (No, unset() only decrements the refcount, the calling of the destructor is a side-effect)

Backward Incompatible Changes

That would break code relying on destructors to be called in a specific context. Which shouldn't be relied on. It only works in special cases like no cyclic references.

Proposed PHP Version(s)

Next minor PHP version to come (7.0 in this case).

Proposed Voting Choices

This vote doesn't affect the language itself, so it requires a 50%+1 majority.



rfc/undeterministic_exceptions.1423857161.txt.gz · Last modified: 2017/09/22 13:28 (external edit)