mirror of
https://github.com/php/php-src.git
synced 2024-09-21 18:07:23 +00:00
1173c2e64a
Generators that suspended a fiber should not be dtor because they will be executed during the fiber dtor. Fiber dtor throws an exception in the fiber's context in order to unwind and execute finally blocks, which will also properly dtor the generator. Fixes GH-9916
48 lines
823 B
PHP
48 lines
823 B
PHP
--TEST--
|
|
Bug GH-9916 008 (Entering shutdown sequence with a fiber suspended in a Generator emits an unavoidable fatal error or crashes)
|
|
--FILE--
|
|
<?php
|
|
$it = new class implements Iterator
|
|
{
|
|
public function current(): mixed
|
|
{
|
|
return null;
|
|
}
|
|
|
|
public function key(): mixed
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
public function next(): void
|
|
{
|
|
}
|
|
|
|
public function rewind(): void
|
|
{
|
|
$x = new stdClass;
|
|
print "Before suspend\n";
|
|
Fiber::suspend();
|
|
}
|
|
|
|
public function valid(): bool
|
|
{
|
|
return true;
|
|
}
|
|
};
|
|
|
|
$gen = (function() use ($it) {
|
|
$x = new stdClass;
|
|
yield from $it;
|
|
})();
|
|
$fiber = new Fiber(function() use ($gen, &$fiber) {
|
|
$gen->current();
|
|
print "Not executed";
|
|
});
|
|
$fiber->start();
|
|
?>
|
|
==DONE==
|
|
--EXPECT--
|
|
Before suspend
|
|
==DONE==
|