|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2012-08-06 22:20 UTC] valentiny510 at yahoo dot es
Description:
------------
Is a little hard to explain becouse are many scenarios where the shutdown function fail or the php doesn't handle correctly the errors but the most simplest method is shown bellow.
Normally, without the register_shutdown_function works well, but if I add the function into the __construct and the child class does not have defined the __construct then fail.
To work well I need to add the __construct function to the child, but if I dont, why the php doesnt throw me an error with $file, $line etc ?
I have many scripts and different scenarios where fail but this I think is the worst becouse it crush all the server.
Sorry but I cant provide any backtrace in this moment
Test script:
---------------
class test1 {
public function __construct() {
register_shutdown_function(array($this, 'shut')); }
public function shutdown() { exit ('Shutdown'); }
}
class test2 extends test1 {
public function __destruct() { exit (__METHOD__); }
}
new test1;
new test2;
Expected result:
----------------
test2::__destruct
Shutdown
or
Shutdown
test2::__destruct
depending of the priority
Actual result:
--------------
All server crush and restart
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 08:00:02 2025 UTC |
I get the following error with a debug build of the current 5.4 tree (Linux, x86): adam@eden:~$ php /tmp/test.php Shutdown test2::__destruct/home/adam/trees/php-src/5.4/Zend/zend_hash.c(551) : ht=0xb6731b50 is being destroyed I had to alter the script slightly to make it run; what I ended up using was: <?php class test1 { public function __construct() { register_shutdown_function(array($this, 'shutdown')); } public function shutdown() { exit ("Shutdown\n"); } } class test2 extends test1 { public function __destruct() { exit (__METHOD__); } } new test1; new test2; ?> The backtrace at the point of the consistency check: Breakpoint 1, zend_hash_destroy (ht=0xb6fb2b1c) at /home/adam/trees/php- src/5.4/Zend/zend_hash.c:551 551 IS_CONSISTENT(ht); (gdb) bt #0 zend_hash_destroy (ht=0xb6fb2b1c) at /home/adam/trees/php- src/5.4/Zend/zend_hash.c:551 #1 0x084218d5 in php_free_shutdown_functions () at /home/adam/trees/php- src/5.4/ext/standard/basic_functions.c:5043 #2 0x0842188f in php_call_shutdown_functions () at /home/adam/trees/php- src/5.4/ext/standard/basic_functions.c:5034 #3 0x0853a400 in php_request_shutdown (dummy=0x0) at /home/adam/trees/php- src/5.4/main/main.c:1718 #4 0x086d3408 in do_cli (argc=2, argv=0xbffff3a4) at /home/adam/trees/php- src/5.4/sapi/cli/php_cli.c:1171 #5 0x086d3c03 in main (argc=2, argv=0xbffff3a4) at /home/adam/trees/php- src/5.4/sapi/cli/php_cli.c:1364