Bug #71604 [Opn->Csd]: Aborted Generators continue after nested finally

From: Date: Sat, 28 May 2016 12:40:56 +0000
Subject: Bug #71604 [Opn->Csd]: Aborted Generators continue after nested finally
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-201307@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=71604&edit=1 ID: 71604 Updated by: nikic@php.net Reported by: bwoebi@php.net Summary: Aborted Generators continue after nested finally -Status: Open +Status: Closed Type: Bug Package: Scripting Engine problem Operating System: Irrelevant PHP Version: 5.6Git-2016-02-16 (Git) Block user comment: N Private report: N New Comment: Automatic comment on behalf of nikic Revision: http://git.php.net/?p=php-src.git;a=commit;h=921b3251b36eb5a930eb3de3496215833d3d548f Log: Fix bug #71604 Previous Comments: ------------------------------------------------------------------------ [2016-02-16 02:20:32] bwoebi@php.net 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 this bug report at https://bugs.php.net/bug.php?id=71604&edit=1

« previous php.bugs (#201307) next »