Skip to content

PHPDbg misidentifies uncaught exception when exception is not yet loaded #22168

@rrehbein

Description

@rrehbein

Description

The following code:

<?php declare(strict_types=1);

try {
    throw new RuntimeException();
} catch (LibrarySpecificException) {
    // A library specific exception. Not autoloaded since it did not happen.
} catch (RuntimeException) {
    echo "Caught it. 'handled' it\n";
}

When run via php or phpdbg -qrr Resulted in this output:

Caught it. 'handled' it

But when run via phpdbg -r resulted in output:

[Welcome to phpdbg, the interactive PHP debugger, v8.5.6]
To get help using phpdbg type "help" and press enter
[Please report bugs to <https://github.com/php/php-src/issues>]
[PHP Fatal error:  During class fetch: Uncaught RuntimeException in /src/demo.php:4
Stack trace:
#0 {main} in /src/demo.php on line 4
Stack trace:
#0 {main}]
>00004:     throw new RuntimeException();
 00005: } catch (LibrarySpecificException) {
 00006:     // A library specific exception. Not autoloaded since it did not happen.
prompt> 

PHP Version

PHP 8.5.6 (cli) (built: May  8 2026 16:44:06) (NTS)
Copyright (c) The PHP Group
Built by https://github.com/docker-library/php
Zend Engine v4.5.6, Copyright (c) Zend Technologies
    with Zend OPcache v8.5.6, Copyright (c), by Zend Technologies


PHP 8.4.20 (cli) (built: Apr  8 2026 08:16:38) (NTS gcc x86_64)
Copyright (c) The PHP Group
Built by Amazon Linux
Zend Engine v4.4.20, Copyright (c) Zend Technologies
    with Zend OPcache v8.4.20, Copyright (c), by Zend Technologies

Operating System

Alpine3.22 and Amazon Linx 2023

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions