Bug #71013 [NEW]: Incorrect exception handler with `yield from`

From: Date: Wed, 02 Dec 2015 18:28:09 +0000
Subject: Bug #71013 [NEW]: Incorrect exception handler with `yield from`
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-197562@lists.php.net to get a copy of this message
From: srice at fb dot com Operating system: Linux PHP version: 7.0.0RC8 Package: Scripting Engine problem Bug Type: Bug Bug description:Incorrect exception handler with yield from Description: ------------ yield from seems to sometimes be executing the incorrect catch block when handling exceptions. When the exception is thrown during the execution of the generator, rather than as an explicit throw() call, it seems that sometimes catch blocks from calling frames can be skipped. Test script: --------------- There are two scripts which exhibit incorrect behavior. 1) https://3v4l.org/KLdee In this example, notice the catch block in bar() is executed, when really the exception happened inside of the yield from in the try block, so the catch block in foo() should be executed. 2) https://3v4l.org/oMdRC In this example (which is only different from the previous example by the addition of the yield 1 in foo() and an equivalent next() in bar()), notice that neither of the exception handlers are called. Expected result: ---------------- For both 1) and 2) Starting bar() Constructing new FooBar Destructing FooBar [foo()] Caught Exception NULL Unsetting $x Finishing bar() Actual result: -------------- 1) Starting bar() Constructing new FooBar Destructing FooBar [bar()] Caught Exception Unsetting $x Finishing bar() 2) Starting bar() Constructing new FooBar Destructing FooBar Fatal error: Uncaught Exception in /in/oMdRC:6 Stack trace: #0 [internal function]: FooBar->current() #1 /in/oMdRC(26): Generator->next() #2 /in/oMdRC(37): bar() #3 {main} thrown in /in/oMdRC on line 6 Process exited with code 255. -- Edit bug report at https://bugs.php.net/bug.php?id=71013&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=71013&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=71013&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=71013&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=71013&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=71013&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=71013&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=71013&r=needscript Try newer version: https://bugs.php.net/fix.php?id=71013&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=71013&r=support Expected behavior: https://bugs.php.net/fix.php?id=71013&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=71013&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=71013&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=71013&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=71013&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=71013&r=dst IIS Stability: https://bugs.php.net/fix.php?id=71013&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=71013&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=71013&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=71013&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=71013&r=mysqlcfg

« previous php.bugs (#197562) next »