Wrong implementation of checking PLUGIN_VAR_SET condition
This issue is MariaDB specific. MySQL is not implement this condition checking.
In sql_plugin.cc, MariaDB implements PLUGIN_VAR_STR check as follows:
But, this implementation has a critical bug which causes SEGV.
This SEGV issues causes as follows:
- Build latest Mroonga
- Install built Mroonga into MariaDB
- MySQL client lost connection against mysqld.
Because, these phenomena causes wrong condition about PLUGIN_VAR_STR.
In include/mysql/plugin.h, a series of PLUGIN_* value defined.
But, these value has a misleading point.
Here is the misleading point:
From PLUGIN_VAR_BOOL to PLUGIN_VAR_DOUBLE are not assumed as a flag. But, defined after PLUGIN_VAR_UNSIGNED macro value are designed as a flag.
OK, let's apply above description in practice.
Here is the line which has causes problem:
From above description,
is valid, because PLUGIN_VAR_NOCMDOPT and PLUGIN_VAR_MEMALLOC are designed as a flag. It is valid.
is invalid code. Because,
In more detail, PLUGIN_VAR_STR and PLUGIN_VAR_SET are defined as follows in include/mysql/plugin.h:
So, PLUGIN_VAR_SET & PLUGIN_VAR_STR ( 0x0007 AND 0x0005) equals PLUGIN_VAR_STR (0x0005).
This result causes following bug:
In latest Mroonga, specifies PLUGIN_VAR_SET ( https://github.com/mroonga/mroonga/blob/master/ha_mroonga.cpp#L965 ), not specifies PLUGIN_VAR_STR. But,
matches PLUGIN_VAR_STR, in spite of PLUGIN_VAR_STR is not set (NULL).
As a result, causes SEGV and not to be able to register Mroonga storage engine plugin into MariaDB.
I've added a fix patch which is written by Kohei Sutou.
original patch found by (Sorry, this email is in Japanese...) : http://sourceforge.jp/projects/groonga/lists/archive/dev/2015-January/003067.html