Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generator memory leak when interrupted during argument evaluation #9750

Closed
arnaud-lb opened this issue Oct 14, 2022 · 1 comment
Closed

Generator memory leak when interrupted during argument evaluation #9750

arnaud-lb opened this issue Oct 14, 2022 · 1 comment

Comments

@arnaud-lb
Copy link
Member

Description

Found while looking at #9735

The following code:

<?php

function f() {
}

$gen = function () use (&$gen) {
    f($gen, yield);
};

$gen = $gen();

foreach ($gen as $value) {
    break;
}

$gen = null;

gc_collect_cycles();

Resulted in this output:

[Fri Oct 14 15:51:40 2022]  Script:  'gen.php'
Zend/zend_generators.c(409) :  Freeing 0x00007fb3a365d3c0 (272 bytes), script=gen.php
=== Total 1 memory leaks detected ===

But I expected this output instead:

PHP Version

PHP 8.1 24c2970

Operating System

No response

@arnaud-lb arnaud-lb self-assigned this Oct 15, 2022
@arnaud-lb arnaud-lb changed the title Generator memory leak when interrupted while the generator is on the stack Generator memory leak when interrupted during argument evaluation Oct 15, 2022
@arnaud-lb
Copy link
Member Author

Fixed in #9756

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants
@arnaud-lb and others