Bug #56649 Valgrind warnings for memory leak in semisync plugin (Delegate class)
Submitted: 8 Sep 2010 13:56 Modified: 14 Dec 2010 6:36
Reporter: Sven Sandberg Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Replication Severity:S2 (Serious)
Version:trunk, 5.6 OS:Any
Assigned to: Zhenxing He CPU Architecture:Any
Tags: memory leak, replication, semisync, valgrind

[8 Sep 2010 13:56] Sven Sandberg
Description:
This is one of several Valgrind warnings for trunk-bugfixing in pb2 at https://central.sun.net/http://pb2.norway.sun.com/?action=archive_download&archive_id=2239... . In rpl.rpl_semi_sync_event:

24 bytes in 1 blocks are definitely lost in loss record 3 of 8
   at 0x4A05809: malloc (vg_replace_malloc.c:149)
   by 0xA850A9: operator new(unsigned long) (my_new.cc:27)
   by 0x6AF68C: Delegate::add_observer(void*, st_plugin_int*) (rpl_handler.h:55)
   by 0x6AD233: register_binlog_relay_io_observer (rpl_handler.cc:529)
   by 0x23B4E00D: ???
   by 0x5CF109: plugin_initialize(st_plugin_int*) (sql_plugin.cc:1046)
   by 0x5CF534: mysql_install_plugin(THD*, st_mysql_lex_string const*, st_mysql_lex_string const*) (sql_plugin.cc:1753)
   by 0x5C1BAD: mysql_execute_command(THD*) (sql_parse.cc:4315)
   by 0x5C2581: mysql_parse(THD*, char*, unsigned, Parser_state*) (sql_parse.cc:5586)
   by 0x5C3BAD: dispatch_command(enum_server_command, THD*, char*, unsigned) (sql_parse.cc:1130)
   by 0x5C5017: do_command(THD*) (sql_parse.cc:802)
   by 0x68A400: do_handle_one_connection(THD*) (sql_connect.cc:1192)
   by 0x68A4FC: handle_one_connection (sql_connect.cc:1131)
   by 0x8AC99A: pfs_spawn_thread (pfs.cc:1061)
   by 0x30242062F6: start_thread (in /lib64/libpthread-2.5.so)
   by 0x30236D1B6C: clone (in /lib64/libc-2.5.so)

This and several other memory leaks that have a stack trace seem to be related to plugins. In this particular case, memory is allocated when Delegate::add_observer() is called, and never freed.

How to repeat:
Read the log.

Suggested fix:
Not sure: should Delegate::~Delegate free this memory, or should the caller also call Delegate::remove_observer()?
[8 Sep 2010 13:59] Sven Sandberg
See also BUG#56650 and BUG#56652.
[20 Oct 2010 11:26] Sven Sandberg
This happened again on http://pb2.norway.sun.com/web.py?template=show_pushes&branch=mysql-next-mr ,  push http://pb2.norway.sun.com/web.py?template=push_details&push=1606993 , valgrind host, test case rpl_semi_sync_event. So setting to verified.
[27 Oct 2010 9:53] Sven Sandberg
This has happened again in mysql-trunk-bugfixing. See http://tinyurl.com/39qgbs8
[4 Nov 2010 7:04] 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/122789

3323 He Zhenxing	2010-11-04
      BUG#56649 Valgrind warnings for memory leak in semisync plugin (Delegate class)
      
      The Observer_info object allocated when INSTALL semisync plugin was
      not free after UNINSTALL the plugin.
      
      Fixed the problem by free the object when UNINTSALL.
[17 Nov 2010 8:59] 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/124110

3345 He Zhenxing	2010-11-17
      BUG#56649 Valgrind warnings for memory leak in semisync plugin (Delegate class)
      
      The Observer_info object allocated when INSTALL semisync plugin was
      not free after UNINSTALL the plugin.
      
      Fixed the problem by free the object when UNINTSALL.
[17 Nov 2010 9:10] Zhenxing He
Pushed to trunk-bugfixing
[5 Dec 2010 12:43] Bugs System
Pushed into mysql-trunk 5.6.1 (revid:alexander.nozdrin@oracle.com-20101205122447-6x94l4fmslpbttxj) (version source revid:alexander.nozdrin@oracle.com-20101205122447-6x94l4fmslpbttxj) (merge vers: 5.6.1) (pib:23)
[14 Dec 2010 6:36] Jon Stephens
Issue does not appear in a 5.6 release; no changelog entry needed. Closed.