Edit report at https://bugs.php.net/bug.php?id=62763&edit=1

 ID:                 62763
 Updated by:         larue...@php.net
 Reported by:        valentiny510 at yahoo dot es
 Summary:            register_shutdown_function and extending class
-Status:             Verified
+Status:             Closed
 Type:               Bug
 Package:            Scripting Engine problem
 Operating System:   XP
 PHP Version:        5.4.5
-Assigned To:        
+Assigned To:        laruence
 Block user comment: N
 Private report:     N

 New Comment:

This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.




Previous Comments:
------------------------------------------------------------------------
[2012-08-12 12:55:28] larue...@php.net

Automatic comment on behalf of laruence
Revision: 
http://git.php.net/?p=php-src.git;a=commit;h=4970926e4543c15e16b0c047d85dddfb4c09b581
Log: Fixed bug #62763 (register_shutdown_function and extending class)

------------------------------------------------------------------------
[2012-08-07 04:52:39] valentiny510 at yahoo dot es

P.S. 2 :D Sorry.
The errors...

[07-Aug-2012 05:39:51 UTC] PHP Warning:  (Registered shutdown functions) Unable 
to call test1::shutdown() - function does not exist in Unknown on line 0

[07-Aug-2012 05:39:51 UTC] PHP Warning:  (Registered shutdown functions) Unable 
to call test2::shutdown() - function does not exist in Unknown on line 0

are shown when the function "shutdown" is private.

If I "exit" it crush the server but if I "echo" the result is

Shutdown
Shutdown
test2::__destruct

Now.. why it output twice when I dont even called parent::__construct ?

If I add an empty __construct function to the child the output is

test2::__destruct
Shutdown

Note also the called order...

------------------------------------------------------------------------
[2012-08-07 02:10:36] valentiny510 at yahoo dot es

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.

------------------------------------------------------------------------
[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

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=62763


-- 
Edit this bug report at https://bugs.php.net/bug.php?id=62763&edit=1

Reply via email to