Bug #76007 [Opn->Ver]: Different garbage collection behavior on PHP7.1 and 7.2

From: Date: Sat, 06 Oct 2018 21:58:40 +0000
Subject: Bug #76007 [Opn->Ver]: Different garbage collection behavior on PHP7.1 and 7.2
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-217451@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=76007&edit=1

 ID:                 76007
 Updated by:         cmb@php.net
 Reported by:        maestroprog at gmail dot com
 Summary:            Different garbage collection behavior on PHP7.1 and
                     7.2
-Status:             Open
+Status:             Verified
 Type:               Bug
 Package:            Scripting Engine problem
 Operating System:   Ubuntu Artful
 PHP Version:        7.2.2
 Block user comment: N
 Private report:     N

 New Comment:

I can confirm this behavioral change, which has been introduced
with commit fac9565[1].

[1] <http://git.php.net/?p=php-src.git;a=commit;h=fac95658b3201fdc7924cd3afa44a5f7afc194aa>


Previous Comments:
------------------------------------------------------------------------
[2018-02-25 22:22:22] maestroprog at gmail dot com

Description:
------------
This (test script) code on PHP 7.1 throws the exception.
But on PHP 7.2 there is no such.


But if write at the end of the script:

unset($generator);

then PHP 7.2 throws the exception.

Sample: https://3v4l.org/JQEOj

Test script:
---------------
<?php
function shutdown(): \Generator
{
    try {
        yield;
    } finally {
        echo 'UNSET BEFORE yield', PHP_EOL;
        yield;
    }
}

$generator = shutdown();
$generator->rewind();

Expected result:
----------------
UNSET BEFORE yield

Fatal error: Uncaught Error: Cannot yield from finally in a force-closed generator...

Actual result:
--------------
UNSET BEFORE yield



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=76007&edit=1


Thread (3 messages)

« previous php.bugs (#217451) next »