Skip to content

Fatal error: Uncaught FiberError: Cannot suspend in a force-closed fiber #98

@EdmondDantes

Description

@EdmondDantes

Sometimes, I encounter an error of this kind.

Environment:

PHP 8.3.4 (cli) (built: Mar 13 2024 11:43:12) (ZTS Visual C++ 2019 x64)
Copyright (c) The PHP Group
Zend Engine v4.3.4, Copyright (c) Zend Technologies
with Xdebug v3.3.2, Copyright (c) 2002-2024, by Derick Rethans

Windows 11

Unfortunately, I can’t identify a clear pattern to reproduce this issue.
I’ve looked into the PHP Fiber code a bit and found that the situation occurs if a Fiber is destroyed in a destructor. However... for some reason, the code involving it continues to execute even after the destructor has been called.

I understand that this is a challenging case to capture. So far, I can’t provide more information. I tried to understand the situation through step-by-step debugging, but… I didn’t see anything suspicious. If I could catch the moment when the Fiber destructor is called and see why the code continues after that, I could easily pinpoint the problem. But I don’t know how to catch the destructor call point.

Maybe you know something about this issue. Thank you!

Error occured here:
Revolt\EventLoop\Internal\AbstractDriver

unset($callback, $args);

            if ($this->interrupt) {
                /** @noinspection PhpUnhandledExceptionInspection */
                \Fiber::suspend($this->internalSuspensionMarker);
            }

Trace:

Fatal error: Uncaught FiberError: Cannot suspend in a force-closed fiber in C:\work\ct\ifcastle-amphp-web-server\vendor\revolt\event-loop\src\EventLoop\Internal\AbstractDriver.php:436
Stack trace:
#0 C:\work\ct\ifcastle-amphp-web-server\vendor\revolt\event-loop\src\EventLoop\Internal\AbstractDriver.php(436): Fiber::suspend(Object(stdClass))
#1 C:\work\ct\ifcastle-amphp-web-server\vendor\revolt\event-loop\src\EventLoop\Internal\AbstractDriver.php(562): Revolt\EventLoop\Internal\AbstractDriver->invokeMicrotasks()
#2 [internal function]: Revolt\EventLoop\Internal\AbstractDriver->Revolt\EventLoop\Internal\{closure}()
#3 {main}
  thrown in C:\work\ct\ifcastle-amphp-web-server\vendor\revolt\event-loop\src\EventLoop\Internal\AbstractDriver.php on line 436

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions