Bug #54253 memory leak when using I_S plugins w/o deinit method
Submitted: 5 Jun 2010 8:18 Modified: 15 Oct 2010 10:38
Reporter: Sergei Golubchik Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Information schema Severity:S3 (Non-critical)
Version:5.1, 5.6.99 bzr OS:Any
Assigned to: Ramil Kalimullin CPU Architecture:Any
Tags: Leak, memory leak

[5 Jun 2010 8:18] Sergei Golubchik
Description:
deinit method is optional in plugins. Still, when a ST_SCHEMA_TABLE is allocated in sql_show.cc for a I_S plugin, it is freed like this:

  if (schema_table && plugin->plugin->deinit)
  {
    if (plugin->plugin->deinit(NULL))
    {
      DBUG_PRINT("warning", ("Plugin '%s' deinit function returned error.",
                             plugin->name.str));
    }
    my_free(schema_table, MYF(0));
  }

which means that if a plugin has no deinit method, the memory will not be freed.
It's wrong, the memory was allocated by the server even for plugins without deinit method - it had to be freed by the server also for plugins without deinit method.

How to repeat:
see sql_show.cc
int finalize_schema_table(st_plugin_int *plugin)

Suggested fix:
move my_free down
[7 Jun 2010 7:39] Sveta Smirnova
Thank you for the report.

Verified as described.
[27 Aug 2010 7:44] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/116959

3492 Ramil Kalimullin	2010-08-27
      Fix for bug #54253: memory leak when using I_S plugins w/o deinit method
      
      Free memory allocated by the server for all plugins,
      with or without deinit() method.
     @ sql/sql_show.cc
        Fix for bug #54253: memory leak when using I_S plugins w/o deinit method
        
        Free memory allocated by the server for all plugins,
        with or without deinit() method.
[1 Sep 2010 13:13] Bugs System
Pushed into mysql-trunk 5.6.1-m4 (revid:alik@sun.com-20100901130501-4g2k86dub29auj8y) (version source revid:alik@sun.com-20100901130012-9bmmvzcnnw6n5rw6) (merge vers: 5.6.1-m4) (pib:21)
[1 Sep 2010 13:14] Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20100901130614-pgop3m80rmutewxn) (version source revid:alik@sun.com-20100901130033-8k19cjn6n2blm3py) (pib:21)
[1 Sep 2010 13:15] Bugs System
Pushed into mysql-5.5 5.5.7-m3 (revid:alik@sun.com-20100901125952-4hsrosoa0xreionr) (version source revid:alik@sun.com-20100901125952-4hsrosoa0xreionr) (merge vers: 5.5.7-m3) (pib:21)
[2 Sep 2010 1:04] Paul DuBois
Noted in 5.1.51, 5.5.7, 5.6.1 changelogs.

INFORMATION_SCHEMA plugins with no deinit() method resulted in a
memory leak.
[28 Sep 2010 8:49] Bugs System
Pushed into mysql-5.1 5.1.52 (revid:sunanda.menon@sun.com-20100928083322-wangbv97uobu7g66) (version source revid:sunanda.menon@sun.com-20100928083322-wangbv97uobu7g66) (merge vers: 5.1.52) (pib:21)
[14 Oct 2010 8:36] Bugs System
Pushed into mysql-5.1-telco-7.0 5.1.51-ndb-7.0.20 (revid:martin.skold@mysql.com-20101014082627-jrmy9xbfbtrebw3c) (version source revid:martin.skold@mysql.com-20101014082627-jrmy9xbfbtrebw3c) (merge vers: 5.1.51-ndb-7.0.20) (pib:21)
[14 Oct 2010 8:51] Bugs System
Pushed into mysql-5.1-telco-6.3 5.1.51-ndb-6.3.39 (revid:martin.skold@mysql.com-20101014083757-5qo48b86d69zjvzj) (version source revid:martin.skold@mysql.com-20101014083757-5qo48b86d69zjvzj) (merge vers: 5.1.51-ndb-6.3.39) (pib:21)
[14 Oct 2010 9:06] Bugs System
Pushed into mysql-5.1-telco-6.2 5.1.51-ndb-6.2.19 (revid:martin.skold@mysql.com-20101014084420-y54ecj85j5we27oa) (version source revid:martin.skold@mysql.com-20101014084420-y54ecj85j5we27oa) (merge vers: 5.1.51-ndb-6.2.19) (pib:21)
[15 Oct 2010 10:38] Jon Stephens
Already documented in the 5.1.51 changelog. No new changelog entries required. Setting back to Closed.