[php-src] PR #25231: Fix GH-11821: Allow graceful exit during class fetch without uncaught error
| From: | prateekbhujel | Date: | Fri, 06 Nov 2026 07:45:33 +0000 |
| Subject: | [php-src] PR #25231: Fix GH-11821: Allow graceful exit during class fetch without uncaught error | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-40345@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/25231
Author: prateekbhujel
Closes GH-11821.
### Description
When an autoloader or error handler terminates via
exit() during a class fetch where
exceptions cannot be thrown (such as trait resolution), report_class_fetch_error()
previously passed the in-flight UnwindExit to
zend_exception_uncaught_error().
Because UnwindExit is an internal unwinding sentinel that does not implement string
conversion, zend_exception_uncaught_error() failed when calling
zval_get_string(), emitting:
```
Warning: Uncaught Error: Object of class UnwindExit could not be converted to string
Fatal error: During class fetch: Uncaught in ...
```
This forced exit status 255 and bypassed object destructors.
### Fix
In report_class_fetch_error(), check if EG(exception) is an
UnwindExit or GracefulExit and return early. This allows the class
declaration opcode (ZEND_DECLARE_CLASS) to proceed to
ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION(), letting the Zend VM opcode loop gracefully
unwind the stack, invoke active destructors, and exit cleanly with the requested status.