ID: 47714
Comment by: crocodile2u at gmail dot com
Reported By: crocodile2u at gmail dot com
Status: Open
Bug Type: Scripting Engine problem
Operating System: Ubuntu 8.10
PHP Version: 5.3.0beta1
New Comment:
> 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"
I am sorry but the error messages are mixed up here.
Correct is:
for __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"
for spl_autoload_register(): "Fatal error: Exception
thrown without a stack frame in Unknown on line 0"
Previous Comments:
------------------------------------------------------------------------
[2009-03-19 08:33:12] crocodile2u at gmail dot com
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.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=47714&edit=1