Closed
Description
Description
When running the following code:
<?php
$fiber = new Fiber(function (): void {
$value = Fiber::suspend('fiber');
echo "Value used to resume fiber: ", $value, PHP_EOL;
});
$value = $fiber->start();
echo "Value from fiber suspending: ", $value, PHP_EOL;
$fiber->__construct(function (): void {
echo "Bar";
$value = Fiber::suspend('new');
echo "Changed: ", $value, PHP_EOL;
});
$fiber->resume('test');
PHP will report a memory leak ("Total 1 memory leaks detected"):
==272678== Memcheck, a memory error detector
==272678== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==272678== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
==272678== Command: sapi/cli/php test2.php
==272678==
Value from fiber suspending: fiber
Value used to resume fiber: test
[Wed Apr 13 20:21:13 2022] Script: 'php-src/test2.php'
php-src/Zend/zend_closures.c(505) : Freeing 0x000000000506a480 (328 bytes), script=php-src/test2.php
=== Total 1 memory leaks detected ===
==272678==
==272678== HEAP SUMMARY:
==272678== in use at exit: 0 bytes in 0 blocks
==272678== total heap usage: 14,370 allocs, 14,370 frees, 2,140,328 bytes allocated
==272678==
==272678== All heap blocks were freed -- no leaks are possible
==272678==
==272678== For lists of detected and suppressed errors, rerun with: -s
==272678== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
PHP Version
PHP 8.2.0-dev (commit 8233e06)
Operating System
Ubuntu 20.04