Open
Description
A variety of issues ranging from segmentation faults to "FiberError: Cannot resume a fiber that is not suspended" are emitted if:
- Running on 8.4+ AND
- Running async logic in a __destruct method of a given class "a" AND
- The garbage collector invokes the __destruct of the event loop before invoking the __destruct method of class "a"
Reproducer:
<?php
use Revolt\EventLoop;
use Revolt\EventLoop\Driver\StreamSelectDriver;
require 'vendor/autoload.php';
final class a {
private static self $a;
public static function getInstance(): self {
return self::$a ??= new self;
}
public function __destruct()
{
var_dump("Destroying ".self::class);
$suspension = EventLoop::getSuspension();
EventLoop::delay(1.0, $suspension->resume(...));
$suspension->suspend();
var_dump("Finished ".self::class);
}
}
EventLoop::defer(function () {
var_dump("start");
});
a::getInstance();
EventLoop::run();
Metadata
Metadata
Assignees
Labels
No labels