php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #76007 Different garbage collection behavior on PHP7.1 and 7.2
Submitted: 2018-02-25 22:22 UTC Modified: 2021-11-10 13:32 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: maestroprog at gmail dot com Assigned: cmb (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 7.2.2 OS: Ubuntu Artful
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
9 + 2 = ?
Subscribe to this entry?

 
 [2018-02-25 22:22 UTC] 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


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-10-06 21:58 UTC] cmb@php.net
-Status: Open +Status: Verified
 [2018-10-06 21:58 UTC] cmb@php.net
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>
 [2021-11-10 13:32 UTC] cmb@php.net
-Status: Verified +Status: Closed -Assigned To: +Assigned To: cmb
 [2021-11-10 13:32 UTC] cmb@php.net
This has apparently been fixed in the meantime[1].

[1] <https://3v4l.org/JQEOj>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 14:01:31 2024 UTC