Bug #71013 [Csd]: Incorrect exception handler with `yield from`
| From: | bwoebi@php.net | Date: | Sun, 06 Dec 2015 01:58:08 +0000 |
| Subject: | Bug #71013 [Csd]: Incorrect exception handler with `yield from` | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-197623@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=71013&edit=1
ID: 71013
Updated by: bwoebi@php.net
Reported by: srice at fb dot com
Summary: Incorrect exception handler with
yield from
Status: Closed
Type: Bug
Package: Scripting Engine problem
Operating System: Linux
PHP Version: 7.0.0RC8
Assigned To: bwoebi
Block user comment: N
Private report: N
New Comment:
Sorry that it took so long, but I was working on something else first ;-)
Nice find though and ⦠fixed!
Previous Comments:
------------------------------------------------------------------------
[2015-12-06 01:56:09] bwoebi@php.net
Automatic comment on behalf of bobwei9@hotmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=559ede17e109adec5dadff3290090e7141ad40ae
Log: Fixed bug #71013 (Incorrect exception handler with yield from)
------------------------------------------------------------------------
[2015-12-06 01:54:42] bwoebi@php.net
Automatic comment on behalf of bobwei9@hotmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=559ede17e109adec5dadff3290090e7141ad40ae
Log: Fixed bug #71013 (Incorrect exception handler with yield from)
------------------------------------------------------------------------
[2015-12-02 18:28:08] srice at fb dot com
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 this bug report at https://bugs.php.net/bug.php?id=71013&edit=1