[PHP-BUG] Bug #71133 [NEW]: segfault on exception from generator

[email protected] ("Bernhard dot Liebl at rz dot uni-regensburg dot de")
Newsgroups php.standards
Message-ID <[email protected]>
From:             Bernhard dot Liebl at rz dot uni-regensburg dot de
Operating system: Linux
PHP version:      5.6.16
Package:          PHP Language Specification
Bug Type:         Bug
Bug description:segfault on exception from generator

Description:
------------
Throwing an exception from a generator under certain conditions produces
a segfault. Happens with php 5.5.9 and php 5.6.16. Seems to be fixed
with php 7.

Test script:
---------------
<?php

$a = function() {
    try {
        yield 1;
    } finally {
        throw new Exception();
    }
};

$b = function() {
    yield 1;
};

echo "starting " . phpversion() . "\n";
try {
    foreach ($a() as $x) {
        foreach ($b() as $y) {
            return true;
        }
    }
} catch (Exception $e) {
    echo "caught exception.\n";
}
echo "exit.\n";

Expected result:
----------------
starting 7.0.0
caught exception.
exit.

Actual result:
--------------
OUTPUT:
starting 5.6.16

COREDUMPS THEN
BACKTRACE:

Program received signal SIGSEGV, Segmentation fault.
0x000000000070d359 in gc_zval_possible_root ()
(gdb) bt
#0  0x000000000070d359 in gc_zval_possible_root ()
#1  0x000000000079b287 in ?? ()
#2  0x0000000000717e28 in execute_ex ()
#3  0x00000000006ddf89 in dtrace_execute_ex ()
#4  0x00000000006efa10 in zend_execute_scripts ()
#5  0x000000000068f845 in php_execute_script ()
#6  0x00000000007a00ce in ?? ()
#7  0x0000000000461d90 in main ()


-- 
Edit bug report at https://bugs.php.net/bug.php?id=71133&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=71133&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=71133&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=71133&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=71133&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=71133&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=71133&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=71133&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=71133&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=71133&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=71133&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=71133&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=71133&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=71133&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=71133&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=71133&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=71133&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=71133&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=71133&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=71133&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=71133&r=mysqlcfg
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.