From: pierre at dotgeek dot org
Operating system: linux
PHP version: 4CVS-2005-08-16 (CVS)
PHP Bug Type: XML related
Bug description: xml_set_element_handler segfaults using object in callback
Description:
------------
xml_set_element_handler segfaults when using a reference to an object or
"this" using 4.4 cvs or stock release.
Reproduce code:
---------------
<?php
class parser {
var $parser = NULL;
var $stack = '';
function parser() {
$this->parser = xml_parser_create();
xml_set_element_handler($this->parser, array(&$this,
'_startElement'), array(&$this, '_endElement'));
}
function _startElement($parser, $tag) {
$this->stack .= $tag . '/';
}
function _endElement($parser, $tag) {
$this->stack .= $tag . '/';
}
}
$parser = new parser();
Expected result:
----------------
no segfault.
Actual result:
--------------
Non debug mode ends with:
*** glibc detected *** ./sapi/cli/php: double free or corruption (!prev):
0x0a1a76b0 ***
======= Backtrace: =========
/lib/libc.so.6[0x174424]
/lib/libc.so.6(__libc_free+0x77)[0x17495f]
./sapi/cli/php[0x80fb268]
./sapi/cli/php(php_XML_ParserFree+0x81)[0x80fd305]
./sapi/cli/php[0x80f87d6]
./sapi/cli/php(list_entry_destructor+0x75)[0x813bf4d]
./sapi/cli/php(zend_hash_del_key_or_index+0x15d)[0x813b511]
./sapi/cli/php(_zend_list_delete+0x58)[0x813bd04]
./sapi/cli/php(_zval_ptr_dtor+0x3d)[0x812e995]
./sapi/cli/php(zend_hash_destroy+0x3c)[0x813a32c]
./sapi/cli/php(_zval_dtor+0x3a)[0x8135f9e]
./sapi/cli/php(_zval_ptr_dtor+0x3d)[0x812e995]
./sapi/cli/php(zend_hash_destroy+0x3c)[0x813a32c]
./sapi/cli/php(_zval_dtor+0x80)[0x8135fe4]
./sapi/cli/php(_zval_ptr_dtor+0x3d)[0x812e995]
./sapi/cli/php[0x80f8822]
./sapi/cli/php(list_entry_destructor+0x75)[0x813bf4d]
./sapi/cli/php[0x813a48b]
./sapi/cli/php(zend_hash_graceful_reverse_destroy+0x17)[0x813a5cb]
./sapi/cli/php(shutdown_executor+0xbf)[0x812ea6f]
./sapi/cli/php(zend_deactivate+0x84)[0x8136c68]
./sapi/cli/php(php_request_shutdown+0x15f)[0x810f6a3]
./sapi/cli/php(main+0x148)[0x8151088]
/lib/libc.so.6(__libc_start_main+0xc6)[0x125de6]
./sapi/cli/php[0x8064c2d]
I can provide a backtrace later if required but the script is here :)
--
Edit bug report at http://bugs.php.net/?id=34150&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=34150&r=trysnapshot4
Try a CVS snapshot (php5.0):
http://bugs.php.net/fix.php?id=34150&r=trysnapshot50
Try a CVS snapshot (php5.1):
http://bugs.php.net/fix.php?id=34150&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=34150&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=34150&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=34150&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=34150&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=34150&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=34150&r=support
Expected behavior: http://bugs.php.net/fix.php?id=34150&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=34150&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=34150&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=34150&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=34150&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=34150&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=34150&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=34150&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=34150&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=34150&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=34150&r=mysqlcfg