[php-src] Issue #9916: Entering shutdown sequence with a fiber suspended in a Generator emits an unavoidable fatal error
| From: | bwoebi | Date: | Thu, 10 Nov 2022 00:08:17 +0000 |
| Subject: | [php-src] Issue #9916: Entering shutdown sequence with a fiber suspended in a Generator emits an unavoidable fatal error | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-242778@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/9916
Author: bwoebi
### Description
The following code:
```php
<?php
$gen = (function() {
try {
Fiber::suspend();
yield;
} finally {
echo "Finally\n";
}
})();
$fiber = new Fiber(function() use ($gen, &$fiber) {
$gen->current();
});
$fiber->start();
```
Resulted in this output (_in Unknown on line 0_ is also very helpful to track the issue down...):
```
Fatal error: Cannot resume an already running generator in Unknown on line 0
```
But I expected this output instead:
```
Finally
```
It seems necessary to add some ordering constraint within the interaction of fibers and generators.
(Swapping the creation of the generator and the fiber in this example poses no problems.)
### PHP Version
master
### Operating System
_No response_