#23078 [NEW]: overload and switch
| From: | bugs dot php dot net at wizzard dot org | Date: | Mon, 07 Apr 2003 06:01:05 +0000 |
| Subject: | #23078 [NEW]: overload and switch | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-37238@lists.php.net to get a copy of this message | ||
From: bugs dot php dot net at wizzard dot org
Operating system: FreeBSD 4.8-RC (recent)
PHP version: 4.3.1
PHP Bug Type: Reproducible crash
Bug description: overload and switch
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 bug report at http://bugs.php.net/?id=23078&edit=1
--
Try a CVS snapshot: http://bugs.php.net/fix.php?id=23078&r=trysnapshot
Fixed in CVS: http://bugs.php.net/fix.php?id=23078&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=23078&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=23078&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=23078&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=23078&r=support
Expected behavior: http://bugs.php.net/fix.php?id=23078&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=23078&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=23078&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=23078&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=23078&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=23078&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=23078&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=23078&r=gnused