Crash in closure code
| From: | Tom Rogers | Date: | Sun, 04 Dec 2005 01:41:18 +0000 |
| Subject: | Crash in closure code | ||
| Groups: | php.gtk.dev | ||
| Request: | Send a blank email to php-gtk-dev+get-2092@lists.php.net to get a copy of this message | ||
Hi
The following sample will cause a crash in windows.
If you change the connect() to connect_simple() no crash
<?php
class window extends GtkWindow {
function __construct() {
parent::__construct();
$this->connect_simple('destroy', array('gtk', 'main_quit'));
$this->set_title('Notebook Demos');
$this->set_default_size(800, 400);
$hbox = new GtkHBox(false, 3);
$this->add($hbox);
$notebook = new GtkNotebook();
$hbox->pack_start($notebook, true);
$notebook->connect('switch_page', array($this,'page_switch'));
$text = new GtkTextView();
$notebook->append_page($text, new GtkLabel('Test'));
$this->show_all();
}
function page_switch($a){
echo "Page switch called.\n";
return;
}
}
new window();
gtk::main();
?>
Here is a stack dump:
_efree(void * 0x00000044, char * 0x010676a4 `string', unsigned int 42, char * 0x00000000,
unsigned int 0) line 286 + 3 bytes
phpg_free_gdkatom_storage(phpg_gdkatom_t * 0x00dc10c8, void * * * 0x00da2938) line 42 + 44 bytes
zend_objects_store_del_ref(_zval_struct * 0x00dc1080, void * * * 0x00da2938) line 169 + 18 bytes
_zval_dtor_func(_zval_struct * 0x00dc1080, char * 0x105b5108 `string', unsigned int 35) line 52
+ 19 bytes
_zval_dtor(_zval_struct * 0x00dc1080, char * 0x105bd874 `string', unsigned int 386) line 35 +
16 bytes
_zval_ptr_dtor(_zval_struct * * 0x00dc0148, char * 0x0106774c `string', unsigned int 141) line
386 + 27 bytes
phpg_closure_marshal(_GClosure * 0x01a35ec0, _GValue * 0x00000000, unsigned int 3, const _GValue *
0x0012f4f4, void * 0x0012f3ac, void * 0x00000000) line 141 + 34 bytes
LIBGOBJECT-2.0-0! 012a34de()
LIBGOBJECT-2.0-0! 012b662e()
LIBGOBJECT-2.0-0! 012b5434()
LIBGOBJECT-2.0-0! 012b5676()
LIBGTK-WIN32-2.0-0! 014f8b59()
LIBGTK-WIN32-2.0-0! 014f9f1e()
LIBGTK-WIN32-2.0-0! 014f953d()
zif_GtkNotebook_append_page(int 2, _zval_struct * 0x00dc0a88, _zval_struct * * 0x00000000,
_zval_struct * 0x00dc0100, int 0, void * * * 0x00da2938) line 26665 + 79 bytes
zend_do_fcall_common_helper_SPEC(_zend_execute_data * 0x0012f908, void * * * 0x00da2938) line 188 +
97 bytes
ZEND_DO_FCALL_BY_NAME_SPEC_HANDLER(_zend_execute_data * 0x0012f908, void * * * 0x00da2938) line 310
+ 13 bytes
execute(_zend_op_array * 0x00dc2db0, void * * * 0x00da2938) line 88 + 15 bytes
zend_do_fcall_common_helper_SPEC(_zend_execute_data * 0x0012fa94, void * * * 0x00da2938) line 222 +
33 bytes
ZEND_DO_FCALL_BY_NAME_SPEC_HANDLER(_zend_execute_data * 0x0012fa94, void * * * 0x00da2938) line 310
+ 13 bytes
execute(_zend_op_array * 0x00dbf7a8, void * * * 0x00da2938) line 88 + 15 bytes
zend_execute_scripts(int 8, void * * * 0x00da2938, _zval_struct * * 0x00000000, int 3) line 1090 +
33 bytes
php_execute_script(_zend_file_handle * 0x0012ff44, void * * * 0x00da2938) line 1704 + 27 bytes
main(int 4, char * * 0x00da2580) line 1039 + 19 bytes
mainCRTStartup() line 338 + 17 bytes
KERNEL32! 7c581af6()
The relevent bit of code from phpg_free_gdkatom_storage()
(object->name is invalid at this point - 0x00000044)
static void phpg_free_gdkatom_storage(phpg_gdkatom_t *object TSRMLS_DC)
{
zend_hash_destroy(object->zobj.properties);
FREE_HASHTABLE(object->zobj.properties);
>>>>> if (object->name) efree(object->name);
efree(object);
}
And from phpg_closure_marshal(); (i=1 and n_param_values = 3)
err_marshal:
efree(callback_name);
i = (phpg_closure->connect_type == PHPG_CONNECT_REPLACE) ? 1 : 0;
for ( ; i < n_param_values; i++) {
>>>>>> zval_ptr_dtor(params[i]);
efree(params[i]);
}
efree(params);
}
Hope this helps.
Let me know if there is something I can do to help further.
--
Tom