|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2009-03-19 08:36 UTC] crocodile2u at gmail dot com
[2009-03-20 00:56 UTC] felipe@php.net
[2009-03-20 06:12 UTC] crocodile2u at gmail dot com
[2009-03-25 11:33 UTC] saschagros at gmail dot com
[2009-03-26 10:57 UTC] dmitry@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 16:00:01 2025 UTC |
Description: ------------ When I use set_exception_handler() and attempt to create an instance of a class inside the handler (the class is not yet loaded and needs to be loaded with __autoload) - I get crashes. The crash type depends on whether I use __autoload() or spl_autoload_register(). I the first case I get "Fatal error: Exception thrown without a stack frame in Unknown on line 0", while in the second I get "Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 72 bytes) in /home/vbolshov/tmp/x.php on line 21 Segmentation fault" It must be noticed, that in case the class already had been loaded by the moment of the exception throw - there are no errors and everything is ok. I am terribly sorry the the reproduce code is longer than 20 lines but it is really simple and I think it shows all the problems. Reproduce code: --------------- <?php /* Uncomment handler class declaration to get rid of crashes */ /* class handler { function handle($e) { echo $e->getMessage()."\n"; } } */ function au($class) { eval('class handler { function handle($e) { echo $e->getMessage()."\n"; } }'); } /* Uncomment __autoload() and comment spl_autoload_register() call to switch between crash types */ /* function __autoload($class) { au($class); } */ spl_autoload_register('au'); set_exception_handler(function($exception) { $h = new handler(); $h->handle($exception); }); throw new Exception('exception'); Expected result: ---------------- exception Actual result: -------------- In case we use spl_autoload_register: -- Fatal error: Exception thrown without a stack frame in Unknown on line 0 -- In case we use __autoload: -- Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 72 bytes) in /home/vbolshov/tmp/x.php on line 21 Segmentation fault -- Works ok when handler class declaration at the top is uncommented.