|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #79753 Fatal error can not be caught - not with catch nor error handler
Submitted: 2020-06-28 12:39 UTC Modified: 2020-07-05 10:46 UTC
From: michael dot vorisek at email dot cz Assigned:
Status: Suspended Package: Scripting Engine problem
PHP Version: Irrelevant OS: any
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: michael dot vorisek at email dot cz
New email:
PHP Version: OS:


 [2020-06-28 12:39 UTC] michael dot vorisek at email dot cz
see test code, there should be a possibility to catch these/all errors

Test script:

class A {
    public function x(): void {}

set_error_handler(function() { echo 'handled'; });

try {
    if (time() > 0) { // wrap in if to make sure an error is not throw at compile time
        class B extends A {
            public function x() {}
} catch (\Throwable $e) {
    echo 'catched';

Expected result:
"handled" or "catched"

Actual result:
fatal error message, no possibility to catch the error


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2020-06-30 14:57 UTC]
-Type: Bug +Type: Feature/Change Request
 [2020-06-30 14:57 UTC]
Well, that is not a bug; changing to feature request.

Note, though, that recovery isn't possible for all error cases.
In this case, it might be possible, but that's not trivial.
 [2020-07-05 10:38 UTC] michael dot vorisek at email dot cz
shutdown function is called when registered:

so parse error should be possible to fix as the VM state is not corrupted
 [2020-07-05 10:46 UTC]
-Status: Open +Status: Suspended
 [2020-07-05 10:46 UTC]
The state is corrupted, e.g. both "new B" and "class B {}" inside the shutdown function will fail. The executor is not unstable, but it also does not satisfy the necessary consistency requirements to make it throw.

I'm suspending this to make it clear that we have no plans to convert this, or other inheritance errors, into exceptions in the near future.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Mon May 10 20:01:23 2021 UTC