[php-src] Issue #8367: Memory leak in Fiber when calling __construct()

From: Date: Wed, 13 Apr 2022 18:25:12 +0000
Subject: [php-src] Issue #8367: Memory leak in Fiber when calling __construct()
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-240939@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/8367 Author: TimWolla ### Description When running the following code: ```php <?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 8233e061091bc442009529d49e4718ea15454e57) ### Operating System Ubuntu 20.04

« previous php.bugs (#240939) next »