[Bug 1042711] [NEW] php: throw and catch within a destructor causes exception on-the-fly to be lost

Mikko Rantalainen mikko.rantalainen at peda.net
Tue Aug 28 12:13:49 UTC 2012


Public bug reported:

See the attached test case. The Outer::runInner() throws a test
exception that is supposed to be catched in Outer::run(). However,
before this the destructor of Inner will run as a result of stack
unwinding while returning from Outer::runInner(). This, in turn, causes
the original exception to be lost because Inner::tearDown() throws an
exception which it later catches.

The test case is expected to output (tested official win32 builds 5.3.16
and 5.4.6):

$ php throw-test.php
Catched exception in Inner::tearDown(): test throw inside Inner::tearDown()
#0 /path/to/test.php(6): Inner->tearDown()
#1 /path/to/test.php(29): Inner->__destruct()
#2 /path/to/test.php(29): Outer->runInner()
#3 /path/to/test.php(45): Outer->run()
#4 {main}
OK: Catched exception in Outer::run(): test throw from Outer::runInner()
#0 /path/to/test.php(29): Outer->runInner()
#1 /path/to/test.php(45): Outer->run()
#2 {main}

The version distributed by ubuntu (PHP 5.3.2-1ubuntu4.17) outputs:

$ php throw-test.php 
Catched exception in Inner::tearDown(): test throw inside Inner::tearDown()
#0 /home/mira/tmp/throw-test.php(6): Inner->tearDown()
#1 /home/mira/tmp/throw-test.php(29): Inner->__destruct()
#2 /home/mira/tmp/throw-test.php(29): Outer->runInner()
#3 /home/mira/tmp/throw-test.php(45): Outer->run()
#4 {main}

Notice the missing exception in Outer::run(). [Lines have been manually
wrapped for this bug report.]

ProblemType: Bug
DistroRelease: Ubuntu 10.04
Package: php5-cli 5.3.2-1ubuntu4.17
ProcVersionSignature: Ubuntu 3.0.0-24.40~lucid1-generic 3.0.38
Uname: Linux 3.0.0-24-generic x86_64
Architecture: amd64
CheckboxSubmission: f0bf0101e3df07a87acfbc156f0db03d
CheckboxSystem: b5acb6c9ca4017b1d44043910f45329d
Date: Tue Aug 28 15:01:35 2012
InstallationMedia: Ubuntu 9.10 "Karmic Koala" - Release Candidate amd64 (20091020.3)
SourcePackage: php5

** Affects: php5 (Ubuntu)
     Importance: Undecided
         Status: New


** Tags: amd64 apport-bug lucid

-- 
You received this bug notification because you are a member of Ubuntu
Server Team, which is subscribed to php5 in Ubuntu.
https://bugs.launchpad.net/bugs/1042711

Title:
  php: throw and catch within a destructor causes exception on-the-fly
  to be lost

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/php5/+bug/1042711/+subscriptions



More information about the Ubuntu-server-bugs mailing list