Description:
If you uninstall a plugin which has a status var which is first in the status var lists and then issues a "show status" statement mysqld will crash.
I reproduced this with a simple plugin (attached) which all that does is register a status var named: AASTAT_example. After uninstall the plugin and issuing a "show status" command mysqld will crash:
mysql> install plugin aastat_example soname 'libaastat_example.so';
Query OK, 0 rows affected (0.02 sec)
mysql> show status like 'AA%';
+----------------+-------+
| Variable_name | Value |
+----------------+-------+
| AASTAT_example | demo |
+----------------+-------+
1 row in set (0.00 sec)
mysql> uninstall plugin aastat_example;
Query OK, 0 rows affected (0.00 sec)
mysql> show status like 'AA%';
ERROR 2013 (HY000): Lost connection to MySQL server during query
How to repeat:
Compile the attached plugin (aastat_example) by adding to the mysql source tree under the "plugin" dir.
Install the plugin then do an uninstall of the plugin.
Then run the command: "show status;".
mysqld will crash.
Suggested fix:
From looking at the source code of sql_show.cc and the function: remove_status_vars it looks like the problem is with the for loop:
for (a= 0, b= all_status_vars.elements; b-a > 1; c= (a+b)/2)
From what I can see "b-a > 1" should be "b-a > 0"
Additionally, it seems there is need to add an assignment to "c" either before the for loop or as part of the for initialization clause.