Exception lost with nested finally block

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

History

AllCommentsChangesGit/SVN commitsRelated reports