#23078 [Opn->Asn]: overload and switch
| From: | sniper@php.net | Date: | Mon, 07 Apr 2003 09:41:05 +0000 |
| Subject: | #23078 [Opn->Asn]: overload and switch | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-37249@lists.php.net to get a copy of this message | ||
ID: 23078
Updated by: sniper@php.net
Reported By: bugs dot php dot net at wizzard dot org
-Status: Open
+Status: Assigned
Bug Type: Scripting Engine problem
Operating System: FreeBSD 4.8-RC (recent)
-PHP Version: 4.3.1
+PHP Version: 4.3.2-RC (latest CVS)
-Assigned To:
+Assigned To: andrei
New Comment:
Assigning to Andrei who wrote this thing, he can decide if it's worth
to fix this.
Previous Comments:
------------------------------------------------------------------------
[2003-04-07 01:01:05] bugs dot php dot net at wizzard dot org
It seems that in a class with overloading enabled, inside a method, if
you switch based on a declared attribute, PHP segfaults. Another
FreeBSD user in #PHP on freenode was able to confirm the problem, using
the following test code.
I've worked out the test case using the CGI binary, but I've also
confirmed that it happens through the APXS2 SAPI. In that case, the
errors from apache are:
[notice] child pid 72051 exit signal Segmentation fault (11)
- and/or -
httpd in free(): warning: chunk is already free
The __get and __set methods are defined here as dummies just so
overloading will truly be enabled. I'm assuming they would not be
called because $var is pre-defined.
Test Code:
<?php
class demo {
var $var;
function demo() {
$this->var = FALSE;
return TRUE;
}
function problem_function() {
switch( $this->var ) {
case 'foo':
break;
}
return TRUE;
}
function __get($name, &$value) {
return TRUE;
}
function __set($name, $value) {
return TRUE;
}
}
overload('demo');
$obj = new demo();
$obj->problem_function();
?>
Backtrace:
(gdb) bt
#0 overload_get_property (property_reference=0xbfbfdfe0)
at
/usr/ports/www/mod_php4/work/php-4.3.1/ext/overload/overload.c:363
#1 0x8144e07 in get_overloaded_property (T=0xbfbfdfd4)
at /usr/ports/www/mod_php4/work/php-4.3.1/Zend/zend_execute.c:929
#2 0x814e2a3 in execute (op_array=0x8301ea4)
at /usr/ports/www/mod_php4/work/php-4.3.1/Zend/zend_execute.c:92
#3 0x814adab in execute (op_array=0x8301424)
at /usr/ports/www/mod_php4/work/php-4.3.1/Zend/zend_execute.c:1640
#4 0x81365f8 in zend_execute_scripts (type=8, retval=0x0,
file_count=3)
at /usr/ports/www/mod_php4/work/php-4.3.1/Zend/zend.c:864
#5 0x810aaea in php_execute_script (primary_file=0xbfbffd0c)
at /usr/ports/www/mod_php4/work/php-4.3.1/main/main.c:1573
#6 0x81532b6 in main (argc=3, argv=0xbfbffd70)
at /usr/ports/www/mod_php4/work/php-4.3.1/sapi/cli/php_cli.c:746
#7 0x80637ca in _start ()
More:
(gdb) f 0
#0 overload_get_property (property_reference=0xbfbfdfe0)
at
/usr/ports/www/mod_php4/work/php-4.3.1/ext/overload/overload.c:363
363 if (Z_TYPE_P(overloaded_property) == OE_IS_OBJECT)
{
(gdb) p overloaded_property
$1 = (zend_overloaded_element *) 0x5a5a5a62
(gdb) p *overloaded_property
Error accessing memory address 0x5a5a5a62: Bad address.
PHP Config Args:
'./configure' '--with-apxs2=/usr/local/sbin/apxs' '--with-tsrm-pth'
'--with-config-file-path=/usr/local/etc' '--enable-versioning'
'--with-regex=system' '--without-gd' '--without-mysql'
'--with-gd=/usr/local' '--enable-gd-native-ttf'
'--with-freetype-dir=/usr/local' '--with-jpeg-dir=/usr/local'
'--with-png-dir=/usr/local' '--with-zlib' '--with-bz2=/usr'
'--with-mcrypt=/usr/local' '--with-mhash=/usr/local'
'--with-imap=/usr/local' '--with-mysql=/usr/local'
'--with-expat-dir=/usr/local' '--with-gettext=/usr/local'
'--enable-debug' '--prefix=/usr/local' 'i386-portbld-freebsd4.8'
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=23078&edit=1