Edit report at https://bugs.php.net/bug.php?id=62763&edit=1
ID: 62763 Comment by: valentiny510 at yahoo dot es Reported by: valentiny510 at yahoo dot es Summary: register_shutdown_function and extending class Status: Verified Type: Bug Package: Scripting Engine problem Operating System: XP PHP Version: 5.4.5 Block user comment: N Private report: N New Comment: Oh yes, sorry, the function called was just "shut" not "shutdown", sorry for that, the test script was writed with some hurry on the web, it was not copied from the actual script, Thank you Aharvey. Previous Comments: ------------------------------------------------------------------------ [2012-08-07 01:33:19] ahar...@php.net 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 ------------------------------------------------------------------------ [2012-08-06 22:53:16] valentiny510 at yahoo dot es P.S. The functions both "exit" and with "echo" I got this errors: [06-Aug-2012 23:48:50 UTC] PHP Warning: (Registered shutdown functions) Unable to call test1::shutdown() - function does not exist in Unknown on line 0 [06-Aug-2012 23:48:50 UTC] PHP Warning: (Registered shutdown functions) Unable to call test2::shutdown() - function does not exist in Unknown on line 0 ------------------------------------------------------------------------ [2012-08-06 22:20:04] 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 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=62763&edit=1