mirror of
https://github.com/php/php-src.git
synced 2024-09-22 10:27:25 +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
38 lines
794 B
PHP
38 lines
794 B
PHP
--TEST--
|
|
Bug GH-9916 006 (Entering shutdown sequence with a fiber suspended in a Generator emits an unavoidable fatal error or crashes)
|
|
--FILE--
|
|
<?php
|
|
$gen = (function() {
|
|
$x = new stdClass;
|
|
yield from (function () {
|
|
$x = new stdClass;
|
|
print "Before suspend\n";
|
|
Fiber::suspend();
|
|
print "After suspend\n";
|
|
yield;
|
|
})();
|
|
yield from (function () {
|
|
$x = new stdClass;
|
|
print "Before exit\n";
|
|
exit;
|
|
print "Not executed\n";
|
|
yield;
|
|
})();
|
|
yield;
|
|
})();
|
|
$fiber = new Fiber(function() use ($gen, &$fiber) {
|
|
$gen->current();
|
|
print "Fiber return\n";
|
|
});
|
|
$fiber->start();
|
|
$fiber->resume();
|
|
$gen->next();
|
|
$gen->current();
|
|
?>
|
|
==DONE==
|
|
--EXPECT--
|
|
Before suspend
|
|
After suspend
|
|
Fiber return
|
|
Before exit
|