PHPDbg misidentifies uncaught exception when exception is not yet loaded
Open
Nobody has claimed this yet.
Bug
SAPI: phpdbg
Status: Needs Triage
- Dominant language
- C
- Stars
- 40.4k
- Forks
- 8.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 96
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the provided script with both phpdbg -r and phpdbg -qrr, comparing them with php. Start at the phpdbg execution path involved in class fetching and exception handling; done means the -r invocation recognizes the uncaught RuntimeException consistently and preserves the expected catch behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100