Skip to content

PHP 8.4: BlueScreen crashes when logging exception thrown from a generator #595

Description

@schlndh

Version: 2.10.10

Bug Description

Starting from PHP 8.4 it's possible to call new ReflectionGenerator($generator) on a closed generator (before 8.4 it throws a ReflectionException which is what Tracy relies on in BlueScreen::findGeneratorsAndFibers). This leads to an unexpected ReflectionException in section-stack-generator.phtml ($ref->getTrace(): it fails if the generator is closed).

Here is an example of the changed behavior.

Steps To Reproduce

Run the following code with PHP 8.4:

$generator = (function (): iterable {
    yield 5;
    throw new \Exception(sprintf('%f', microtime(true)));
})();
$fn = function ($generator)  {
    foreach ($generator as $value) {
    }
};

try {
    $fn($generator);
} catch (Exception $e) {
    echo "exception\n";
    $file = sys_get_temp_dir() . '/' . uniqid('bluescreen_');
    \Tracy\Debugger::getBlueScreen()->renderToFile($e, $file);
}

echo "OK\n";

Expected Behavior

Closed generators should be excluded the same way as they were before PHP 8.4.

Possible Solution

Check ReflectionGenerator::isClosed in findGeneratorsAndFibers.

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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