[php-src] Issue #20619: Autoloader doesn't work in header_register_callback() callback when an exception is being thrown

From: Date: Sat, 29 Nov 2025 19:08:12 +0000
Subject: [php-src] Issue #20619: Autoloader doesn't work in header_register_callback() callback when an exception is being thrown
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-251332@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/20619 Author: tgr ### Description The following code: ```php <?php spl_autoload_register( function () { class Autoloaded {} } ); header_register_callback( function () { new Autoloaded(); } ); throw new Exception(); ``` Resulted in this output: ``` PHP Fatal error: Uncaught Error: Class "Autoloaded" not found in /path/to/foo.php:8 Stack trace: #0 [internal function]: {closure:/path/to/foo.php:7}() #1 {main} thrown in /path/to/foo.php on line 8 ``` But I expected this output instead: ``` Fatal error: Uncaught Exception in /path/to/foo.php:11 Stack trace: #0 {main} thrown in /path/to/foo.php on line 11 ``` Seen on Wikipedia servers first on PHP 7.4 then 8.1, reported on various other versions. Could reproduce locally on 8.5. Can't reproduce it on [3v4l.org](https://3v4l.org/lT1S9) for some reason. ### PHP Version ```plain PHP 8.5.0 (cli) (built: Nov 20 2025 19:23:30) (NTS) Copyright (c) The PHP Group Built by Debian Zend Engine v4.5.0, Copyright (c) Zend Technologies with Zend OPcache v8.5.0, Copyright (c), by Zend Technologies ``` ### Operating System Ubuntu 24.04

« previous php.bugs (#251332) next »