Bug #70012 [NEW]: Exception lost with nested finally block

From: Date: Tue, 07 Jul 2015 15:03:10 +0000
Subject: Bug #70012 [NEW]: Exception lost with nested finally block
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-194179@lists.php.net to get a copy of this message
From:             nickpeirson at gmail dot com
Operating system: Linux (Ubuntu 14.04)
PHP version:      7.0.0alpha2
Package:          Scripting Engine problem
Bug Type:         Bug
Bug description:Exception lost with nested finally block

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

-- 
Edit bug report at https://bugs.php.net/bug.php?id=70012&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=70012&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=70012&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=70012&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=70012&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=70012&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=70012&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=70012&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=70012&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=70012&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=70012&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=70012&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=70012&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=70012&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=70012&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=70012&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=70012&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=70012&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=70012&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=70012&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=70012&r=mysqlcfg



Thread (2 messages)

« previous php.bugs (#194179) next »