php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70012 Exception lost with nested finally block
Submitted: 2015-07-07 15:03 UTC Modified: 2015-07-08 07:18 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: nickpeirson at gmail dot com Assigned: laruence (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 7.0.0alpha2 OS: Linux (Ubuntu 14.04)
Private report: No CVE-ID: None
 [2015-07-07 15:03 UTC] nickpeirson at gmail dot com
Description:
------------
If finally blocks are nested, odd behaviour arises with exceptions. The attached example demonstrates an exception being thrown and never being caught, even though there's an appropriate catch block.

While 5.5 behaves worse, e.g. you end up with an exception you can't catch, this behaviour is still present in 5.6 and 7:
http://3v4l.org/3UF6O



Test script:
---------------
try {
    echo "Outer try\n";
    try {
        echo "  Middle try\n";
        throw new Exception();
    } finally {
        echo "  Middle finally\n";
            try {
                echo "    Inner try\n";
            } finally {
                echo "    Inner finally\n";
            }
    }
    echo "Outer shouldnt get here\n";
} catch (Exception $e) {
    echo "Outer catch\n";
} finally {
    echo "Outer finally\n";
}

Expected result:
----------------
Outer try
  Middle try
  Middle finally
    Inner try
    Inner finally
Outer catch
Outer finally

Actual result:
--------------
Outer try
  Middle try
  Middle finally
    Inner try
    Inner finally
Outer shouldnt get here
Outer finally

Patches

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-07-08 07:18 UTC] laruence@php.net
-Assigned To: +Assigned To: laruence
 [2015-07-08 09:21 UTC] laruence@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=ca30d5bf3947922a618d95f1ae16886204f37292
Log: Fixed bug #70012 (Exception lost with nested finally block)
 [2015-07-08 09:21 UTC] laruence@php.net
-Status: Assigned +Status: Closed
 [2015-07-08 09:21 UTC] laruence@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=c6037bd3af5cc9f42fe02eae2a2066185ba67a69
Log: Fixed bug #70012 (Exception lost with nested finally block)
 [2015-07-21 14:21 UTC] ab@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=c6037bd3af5cc9f42fe02eae2a2066185ba67a69
Log: Fixed bug #70012 (Exception lost with nested finally block)
 [2015-07-21 14:21 UTC] ab@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=ca30d5bf3947922a618d95f1ae16886204f37292
Log: Fixed bug #70012 (Exception lost with nested finally block)
 [2016-07-20 11:37 UTC] davey@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=c6037bd3af5cc9f42fe02eae2a2066185ba67a69
Log: Fixed bug #70012 (Exception lost with nested finally block)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 14:01:29 2024 UTC