#40621 [Opn->Csd]: Crash when constructor called inappropriately (statically)
| From: | tony2001@php.net | Date: | Sat, 24 Feb 2007 21:31:06 +0000 |
| Subject: | #40621 [Opn->Csd]: Crash when constructor called inappropriately (statically) | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-109477@lists.php.net to get a copy of this message | ||
ID: 40621
Updated by: tony2001@php.net
Reported By: sean@php.net
-Status: Open
+Status: Closed
Bug Type: Reproducible crash
Operating System: Linux
PHP Version: 5.2.1
New Comment:
This bug has been fixed in CVS.
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/.
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2007-02-24 20:57:29] sean@php.net
Description:
------------
PHP 5.2.x (tried 5.2.1, 5.2.0) crashes if a constructor is called
statically from within the host class.
Code explains this better.
I realize I'm not SUPPOSED to do this, but I did it accidentally (I
made a mistake). I expect the error message. It shouldn't, however,
crash.
Reproduce code:
---------------
php -r 'class Foo { private function __construct() { } function get() {
self::__construct(); } } Foo::get();'
Expected result:
----------------
E_FATAL
Here's 5.1.6:
Fatal error: Non-static method Foo::__construct() cannot be called
statically in Command line code on line 1
In 5.2.0, this was downgraded to E_STRICT, which I suspect is why it
crashes (E_FATAL would have bailed, E_STRICT tries to run this messed
up code).
Actual result:
--------------
here's the backtrace:
(gdb) run -r 'class Foo { private function __construct() { } function
get() { self::__construct(); } } Foo::get();'
Starting program: /usr/local/bin/php -r 'class Foo { private function
__construct() { } function get() { self::__construct(); } }
Foo::get();'
[Thread debugging using libthread_db enabled]
[New Thread -1214503248 (LWP 28107)]
Strict Standards: Non-static method Foo::get() should not be called
statically in Command line code on line 1
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1214503248 (LWP 28107)]
0x083c425c in zend_get_class_entry (zobject=0x0)
at /home/sean/downloads/php-5.2.1/Zend/zend_API.c:248
248 if (Z_OBJ_HT_P(zobject)->get_class_entry) {
(gdb) bt
#0 0x083c425c in zend_get_class_entry (zobject=0x0)
at /home/sean/downloads/php-5.2.1/Zend/zend_API.c:248
#1 0x083ec877 in ZEND_INIT_STATIC_METHOD_CALL_SPEC_UNUSED_HANDLER (
execute_data=0xbfd5e800)
at /home/sean/downloads/php-5.2.1/Zend/zend_vm_execute.h:1222
#2 0x083e7fc3 in execute (op_array=0xb798f330)
at /home/sean/downloads/php-5.2.1/Zend/zend_vm_execute.h:92
#3 0x083e85ed in zend_do_fcall_common_helper_SPEC
(execute_data=0xbfd5e980)
at /home/sean/downloads/php-5.2.1/Zend/zend_vm_execute.h:234
#4 0x083e90c0 in ZEND_DO_FCALL_BY_NAME_SPEC_HANDLER
(execute_data=0xbfd5e980)
at /home/sean/downloads/php-5.2.1/Zend/zend_vm_execute.h:322
#5 0x083e7fc3 in execute (op_array=0xb798d7fc)
at /home/sean/downloads/php-5.2.1/Zend/zend_vm_execute.h:92
#6 0x083b6e79 in zend_eval_string (
str=0xbfd5f911 "class Foo { private function __construct() { }
function get() { self::__construct(); } } Foo::get();",
retval_ptr=0x0,
string_name=0x8522074 "Command line code")
at /home/sean/downloads/php-5.2.1/Zend/zend_execute_API.c:1151
#7 0x083b7012 in zend_eval_string_ex (
str=0xbfd5f911 "class Foo { private function __construct() { }
function get() { self::__construct(); } } Foo::get();",
retval_ptr=0x0,
string_name=0x8522074 "Command line code", handle_exceptions=1)
at /home/sean/downloads/php-5.2.1/Zend/zend_execute_API.c:1185
#8 0x0843d555 in main (argc=3, argv=0xbfd5ed14)
at /home/sean/downloads/php-5.2.1/sapi/cli/php_cli.c:1153
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=40621&edit=1