#31086 [NEW]: Type hinting in constructor crashes php
| From: | junkmail at konvergencia dot hu | Date: | Tue, 14 Dec 2004 11:49:34 +0000 |
| Subject: | #31086 [NEW]: Type hinting in constructor crashes php | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-70203@lists.php.net to get a copy of this message | ||
From: junkmail at konvergencia dot hu
Operating system: FreeBSD 4.10
PHP version: 5.0.2
PHP Bug Type: Class/Object related
Bug description: Type hinting in constructor crashes php
Description:
------------
If class B's constructor is defined as __construct(A $anObject), calling
new B(new A) without taking the return value causes a crash (SIGBUS).
Not using type hinting or assigning the result to a variable seems to work
around the problem.
E.g. $tmp = new B(new A()) does not produce the crash.
Reproduce code:
---------------
<?php
Class A {
function __construct(){}
}
Class B {
function __construct(A $a){}
}
new B(new A());
echo 'OK';
?>
Expected result:
----------------
A simple OK would be nice ;)
Actual result:
--------------
Program terminated with signal 10, Bus error.
(gdb) bt
#0 zend_std_object_get_class (object=0x84591cc) at
/usr/local/src/php-5.0.2/Zend/zend_object_handlers.c:905
#1 0x81b66dd in zend_get_class_entry (zobject=0x84591cc) at
/usr/local/src/php-5.0.2/Zend/zend_API.c:205
#2 0x81e9d5b in zend_recv_handler (execute_data=0xbfbfe094,
opline=0x8443e58, op_array=0x83a6c0c)
at /usr/local/src/php-5.0.2/Zend/zend_execute.c:345
#3 0x81d0805 in execute (op_array=0x83a6c0c) at
/usr/local/src/php-5.0.2/Zend/zend_execute.c:1400
#4 0x81e8193 in zend_do_fcall_common_helper (execute_data=0xbfbfe254,
opline=0x845a39c, op_array=0x83a660c)
at /usr/local/src/php-5.0.2/Zend/zend_execute.c:2740
#5 0x81e84ed in zend_do_fcall_by_name_handler (execute_data=0xbfbfe254,
opline=0x845a39c, op_array=0x83a660c)
at /usr/local/src/php-5.0.2/Zend/zend_execute.c:2825
#6 0x81d0805 in execute (op_array=0x83a660c) at
/usr/local/src/php-5.0.2/Zend/zend_execute.c:1400
#7 0x81b6195 in zend_execute_scripts (type=8, retval=0x0, file_count=3)
at /usr/local/src/php-5.0.2/Zend/zend.c:1060
#8 0x8187dbb in php_execute_script (primary_file=0xbfbff8d0) at
/usr/local/src/php-5.0.2/main/main.c:1629
#9 0x81f1120 in main (argc=2, argv=0xbfbff948) at
/usr/local/src/php-5.0.2/sapi/cgi/cgi_main.c:1568
(gdb) print zobj
$1 = (zend_object *) 0xffffffff
--
Edit bug report at http://bugs.php.net/?id=31086&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=31086&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=31086&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=31086&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=31086&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=31086&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=31086&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=31086&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=31086&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=31086&r=support
Expected behavior: http://bugs.php.net/fix.php?id=31086&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=31086&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=31086&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=31086&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=31086&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=31086&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=31086&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=31086&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=31086&r=float
MySQL Configuration Error: http://bugs.php.net/fix.php?id=31086&r=mysqlcfg