Uploaded image for project: 'MariaDB Connector/C'
  1. MariaDB Connector/C
  2. CONC-568

Race condition in loading of client plugins

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 3.2.3
    • 3.3.0, 3.2.5, 3.1.15
    • None
    • None

    Description

      When multiple threads in the same application attempt to connect to a server using a client-side authentication plugin, the following error can be observed from time to time.

      1045: Plugin client_ed25519 could not be loaded: it is already loaded
      

      Looking at the code in ma_client_plugin.c.in:

        /* make sure the plugin wasn't loaded meanwhile */
        if (find_plugin(plugin->name, plugin->type))
        {
          my_set_error(mysql, CR_AUTH_PLUGIN_CANNOT_LOAD,
                       SQLSTATE_UNKNOWN, ER(CR_AUTH_PLUGIN_CANNOT_LOAD),
                       plugin->name, "it is already loaded");
          plugin= NULL;
        }
      

      we see that something that can only occur with more than one thread is treated as an error. Additionally, it seems that the initial find_plugin() call is not done under the same lock under which the plugin loading is done. This would explain why more than one thread attempts to load the same plugin.

      I believe that either the whole mysql_client_find_plugin should be covered by the same mutex or the already existing plugin should be returned instead of treating it as an error.

      Attachments

        Activity

          People

            georg Georg Richter
            markus makela markus makela
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.