php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74606 Segfault within try/catch/finally nesting in Generators
Submitted: 2017-05-17 17:52 UTC Modified: -
From: bwoebi@php.net Assigned:
Status: Closed Package: Reproducible crash
PHP Version: 7.1Git-2017-05-17 (Git) OS: Irrelevant
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: bwoebi@php.net
New email:
PHP Version: OS:

 

 [2017-05-17 17:52 UTC] bwoebi@php.net
Description:
------------
Nesting a try/finally inside a try/catch in a loop within a Generator will cause too many live vars to be cleaned up (i.e. outside its live range).

Test script:
---------------
function gen() {
        $array = ["foo"];
        $array[] = "bar";

        foreach ($array as $item) {
                try {
                        try {
                                yield;
                        } finally {
                                echo "fin $item\n";
                        }
                } catch (\Exception $e) {
                        echo "catch\n";
                        continue;
                }
        }
}
$g = gen();
$g->throw(new Exception);

Expected result:
----------------
fin foo
catch
fin bar


Actual result:
--------------
fin foo
catch
fin bar
<segmentation fault>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-05-17 17:59 UTC] bwoebi@php.net
Automatic comment on behalf of bobwei9@hotmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=649494c0ee54102ac4a6c62fd5faf38143efb107
Log: Fixed bug #74606 (Segfault within try/catch/finally nesting in Generators)
 [2017-05-17 17:59 UTC] bwoebi@php.net
-Status: Open +Status: Closed
 [2017-05-17 17:59 UTC] bwoebi@php.net
Automatic comment on behalf of bobwei9@hotmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=649494c0ee54102ac4a6c62fd5faf38143efb107
Log: Fixed bug #74606 (Segfault within try/catch/finally nesting in Generators)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 21:01:36 2024 UTC