Bug #13628 Crash when reading schemata information from server
Submitted: 30 Sep 2005 2:15 Modified: 3 Oct 2005 8:24
Reporter: Daniel Kasak (Candidate Quality Contributor) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Administrator Severity:S2 (Serious)
Version:1.1.2 OS:Linux (Gentoo)
Assigned to: Vladimir Kolesnikov CPU Architecture:Any

[30 Sep 2005 2:15] Daniel Kasak
Description:
I can access *some* databases from administrator, but attempting to access the schemata for others crashes administrator *every* time.

How to repeat:
I'm uploading a 'mysqldump -d' of a database that crashes mysql-administrator *every* time when I click on it.

1) Create a testing database
2) Load up the dump file
3) Open mysql-administrator
4) Click on the testing database you just populated

mysql-administrator should now crash.
[30 Sep 2005 2:16] Daniel Kasak
'mysqldump -d' output

Attachment: NUS_no_data.sql (application/octet-stream, text), 41.77 KiB.

[1 Oct 2005 9:52] Marin Purgar
Confirming on SUSE 9.3 Pro with the version 1.1.3 binaries downloaded from mysql.com and with the version 1.1.2 compiled from the sources.
[1 Oct 2005 9:55] Marin Purgar
Oops, the MySQL version was the 4.1.10a as installed/updated with SUSE 9.3 Pro.
[2 Oct 2005 12:28] Marin Purgar
OK, it seems that it was the bug in the MACatalogsPanel::refresh_index_info. There are two table status (MYX_TABLE STATUS) structures used (ts1 and ts2), where only one can be used. The second one (ts2) is initialized wrongly from the _entity_status->schema_entities (using j instead of i array index variable).

Attached patch (refresh_index_info.diff) fixes the issue.
[2 Oct 2005 12:29] Marin Purgar
Uhm! It seems that I do not have the privileges to attach a file, so:

--- mysql-administrator-1.1.2.orig/mysql-administrator/source/linux/MACatalogsPanel.cc  2005-09-02 13:38:15.000000000 +0200
+++ mysql-administrator-1.1.2/mysql-administrator/source/linux/MACatalogsPanel.cc       2005-10-02 14:21:06.000000000 +0200
@@ -608,7 +608,7 @@

 void MACatalogsPanel::refresh_index_info(const Glib::ustring &catalog,const Glib::ustring &schema)
 {
-  MYX_TABLE_STATUS *ts1, *ts2;
+  MYX_TABLE_STATUS *ts1;

   get_label("index_label")->set_markup(ufmt(_("<b>%s</b>\n"
                                               "All indices in schema '%s'"),
@@ -637,9 +637,8 @@
         {
           continue;
         }
-        ts2= (MYX_TABLE_STATUS *)_entity_status->schema_entities[j].entity;

-        MYX_TABLE_INDEX *index= ts2->indexes+j;
+        MYX_TABLE_INDEX *index= ts1->indexes+j;

         iter= _index_store->append();
         row= *iter;
[2 Oct 2005 13:44] Marin Purgar
And this patch looks even better, no need to check if entity_type is MYX_ENTITY_TABLE since it was already checked (and even with the proper index variable i instead of j).

--- mysql-administrator-1.1.2.orig/mysql-administrator/source/linux/MACatalogsPanel.cc  2005-09-02 13:38:15.000000000 +0200
+++ mysql-administrator-1.1.2/mysql-administrator/source/linux/MACatalogsPanel.cc       2005-10-02 15:48:19.000000000 +0200
@@ -608,7 +608,7 @@

 void MACatalogsPanel::refresh_index_info(const Glib::ustring &catalog,const Glib::ustring &schema)
 {
-  MYX_TABLE_STATUS *ts1, *ts2;
+  MYX_TABLE_STATUS *ts1;

   get_label("index_label")->set_markup(ufmt(_("<b>%s</b>\n"
                                               "All indices in schema '%s'"),
@@ -633,13 +633,7 @@
         Gtk::TreeIter iter;
         Gtk::TreeModel::Row row;

-        if (_entity_status->schema_entities[j].entity_type != MYX_ENTITY_TABLE)
-        {
-          continue;
-        }
-        ts2= (MYX_TABLE_STATUS *)_entity_status->schema_entities[j].entity;
-
-        MYX_TABLE_INDEX *index= ts2->indexes+j;
+        MYX_TABLE_INDEX *index= ts1->indexes+j;

         iter= _index_store->append();
         row= *iter;
[3 Oct 2005 8:24] Vladimir Kolesnikov
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html

Additional info:

Hi  Marin,
thanks for your patch. i didn't use it as noticed it after the fix, but anyway i used a similar approach.