php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #40024 Able to thrown an Exception in a Destructor
Submitted: 2007-01-04 17:57 UTC Modified: 2007-08-17 11:12 UTC
Votes:2
Avg. Score:4.0 ± 1.0
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:1 (50.0%)
From: php at girsbrain dot org Assigned:
Status: Closed Package: Documentation problem
PHP Version: 5.2.0 OS: Windows XP SP 2
Private report: No CVE-ID: None
 [2007-01-04 17:57 UTC] php at girsbrain dot org
Description:
------------
On the Constructor/Destructor page in the manual, the last note states that "Attempting to throw an exception from a destructor causes a fatal error." I've come into a scenario where I am able to throw an Exception, without fail, from a Destructor.

Below are just two examples, I'm sure there are more.

Reproduce code:
---------------
http://www.girsbrain.org/php_bugs/exception_deconstructor_01.phps
http://www.girsbrain.org/php_bugs/exception_deconstructor_02.phps

Expected result:
----------------
Fatal error: Exception thrown without a stack frame in Unknown on line 0

Actual result:
--------------
This should produce a Fatal error, but it doesn't

#0 \test.php(10): TestClass->__destruct()
#1 {main}

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-01-04 18:02 UTC] php at girsbrain dot org
Tested on CentOS 2.6.9-42.0.2.ELsmp #1 SMP Wed Aug 23 13:38:27 BST 2006 GNU/Linux with PHP 5.1.6, got the same result.
 [2007-01-04 18:17 UTC] garmoan at gmail dot com
Tested on Mac OSX with PHP 6.0.0-dev
same results
 [2007-01-10 08:52 UTC] dmitry@php.net
This is a documentation bug.

The "PHP Fatal error:  Exception thrown without a stack frame" is occurs only if exception thrown during PHP script shutdown, however objects that are destroied during script execution can throw exception from destructors without problem.
 [2007-08-17 11:12 UTC] vrana@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.

"Attempting to throw an exception from a destructor (called in the time of script termination) causes a fatal error."
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon May 12 22:01:30 2025 UTC