Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
schlndh opened this issue May 8, 2025 · 0 comments · May be fixed by #596
Open

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

schlndh opened this issue May 8, 2025 · 0 comments · May be fixed by #596

Comments

@schlndh
Copy link

schlndh commented May 8, 2025

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.

schlndh added a commit to schlndh/tracy that referenced this issue May 11, 2025
schlndh added a commit to schlndh/tracy that referenced this issue May 11, 2025
@schlndh schlndh linked a pull request May 11, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant