View Issue Details

IDProjectCategoryView StatusLast Update
0000389XdebugUncategorizedpublic2020-03-18 18:44
Reportersklar Assigned To 
PrioritynormalSeverityfeatureReproducibilityalways
Status closedResolutionfixed 
Summary0000389: Destructors called on fatal error
Description

When xdebug is disabled (or not installed), object destructors are not called on fatal error.

With xdebug enabled, object destructors are called when there's a fatal error.

This can be a big problem if the object destructor behaves unpredictably (or badly) because of whatever caused the fatal error (so that variables expected to be set are not, etc.)

Additional Information

Test script:

<?php

print "xdebug is " . (xdebug_is_enabled() ? "on" : "off") . "\n";

class Food {
public function destruct() {
echo "
destruct called\n";
}
}

$f = new Food();
echo "forcing fatal error:\n";
Abc::def();

?>

==
Xdebug on, problem happens:

% /tmp/php-5.2.6/bin/php test.php
xdebug is on
forcing fatal error:

Fatal error: Class 'Abc' not found in /private/tmp/xdebug-destructor-test/test.php on line 13

Call Stack:
0.0003 52312 1. {main}() /private/tmp/xdebug-destructor-test/test.php:0

__destruct called

==
Xdebug off, no problem:

% /tmp/php-5.2.6/bin/php -d xdebug.default_enable=0 test.php
xdebug is off
forcing fatal error:

Fatal error: Class 'Abc' not found in /private/tmp/xdebug-destructor-test/test.php on line 13

TagsNo tags attached.
Operating SystemOS X: Darwin host.local 8.11.1 Darwin Kernel Version 8.11.1: Wed Oct 10 18:23:28 PDT 2007; root:xnu-792.25.20~1/RELEASE_I386 i386 i386
PHP Version5.2.6

Activities

MP_

2008-10-15 14:58

reporter   ~0000890

While this is unexpected behaviour with standard PHP, it may not be harmful in all cases. My application actually benefits from it. Personally I would prefer if PHP handled a fatal error the same way as with XDebug. If this bug gets fixed, I would like to have this as a configuration option.

k-fish

2008-12-11 21:09

reporter   ~0000898

related to 0000391

derick

2009-12-29 17:00

administrator   ~0001230

Fixed in rev. 3177.

derick

2020-03-18 18:44

administrator   ~0005301

FWIW, PHP 8 now makes destructors get called upon fatal errors. So this bug is now "invalid" for PHP 8. I've disabled the test for that version therefore.

Issue History

Date Modified Username Field Change
2008-07-18 16:00 sklar New Issue
2008-10-15 14:58 MP_ Note Added: 0000890
2008-12-11 21:09 k-fish Note Added: 0000898
2009-12-29 17:00 derick Note Added: 0001230
2009-12-29 17:00 derick Status new => closed
2009-12-29 17:00 derick Resolution open => fixed
2020-03-12 16:55 derick Severity major => feature
2020-03-12 17:16 derick Category Feature/Change request => Uncategorized
2020-03-18 18:44 derick Note Added: 0005301