Bug #71604 [NEW]: Aborted Generators continue after nested finally

From: Date: Tue, 16 Feb 2016 02:20:33 +0000
Subject: Bug #71604 [NEW]: Aborted Generators continue after nested finally
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-199241@lists.php.net to get a copy of this message
From: bwoebi Operating system: Irrelevant PHP version: 5.6Git-2016-02-16 (Git) Package: Scripting Engine problem Bug Type: Bug Bug description:Aborted Generators continue after nested finally Description: ------------ L6 YIELD L8 ECHO "INNER " L8 FAST_RET<TO_CATCH> ~0 try-catch(0) L10 CATCH "Exception" $e 1 and then it goes bad. When reaching the catch without an Exception, it goes to finally without fast_call u2.lineno variable being -1. [Or in master, where there's no target for the last catch, it immediately goes nuts.] Could be easily fixed by just marking the other FAST_RET's fast_call u2.lineno variables as -1, but then there is the second case when an actual exception gets thrown while in finally and caught, where this approach does not work (as there is no further opcode after a successful catch). Test script: --------------- // First example function gen() { try { try { yield; } finally { print "INNER\n"; } } catch (Exception $e) { print "EX\n"; } finally { print "OUTER\n"; } print "NOTREACHED\n"; } gen()->current(); // Second example function gen2() { try { try { yield; } finally { print "INNER\n"; throw new Exception; } } catch (Exception $e) { print "EX\n"; } print "NOTREACHED\n"; } gen2()->current(); Expected result: ---------------- // First example: INNER OUTER // Second example: INNER EX Actual result: -------------- // First example (undefined in master after OUTER step due to the last catch not having a target opline defined) INNER OUTER NOTREACHED // Second example INNER EX NOTREACHED -- Edit bug report at https://bugs.php.net/bug.php?id=71604&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=71604&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=71604&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=71604&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=71604&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=71604&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=71604&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=71604&r=needscript Try newer version: https://bugs.php.net/fix.php?id=71604&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=71604&r=support Expected behavior: https://bugs.php.net/fix.php?id=71604&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=71604&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=71604&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=71604&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=71604&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=71604&r=dst IIS Stability: https://bugs.php.net/fix.php?id=71604&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=71604&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=71604&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=71604&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=71604&r=mysqlcfg

« previous php.bugs (#199241) next »