Bug #78223 memory leak in mysqlbinlog
Submitted: 26 Aug 2015 12:59 Modified: 21 Apr 2016 16:21
Reporter: Tor Didriksen Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S3 (Non-critical)
Version:5.7.9 OS:Any
Assigned to: Andrei Elkin CPU Architecture:Any

[26 Aug 2015 12:59] Tor Didriksen
Description:
The patch for
    Bug#21672747 ADD MTR OPTION TO RUN ALL CLIENT APPLICATIONS WITH VALGRIND
introduced a new --valgrind-clients option for mtr.
It shows memory leaks in mysqlbinlog.

==19724== 100 bytes in 2 blocks are indirectly lost in loss record 15 of 20
==19724==    at 0x4C2745D: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==19724==    by 0x48AF32: my_raw_malloc (my_malloc.c:191)
==19724==    by 0x48AB32: my_malloc (my_malloc.c:54)
==19724==    by 0x48B203: my_strndup (my_malloc.c:318)
==19724==    by 0x515E7B: bapi_strndup(char const*, unsigned long) (wrapper_functions.h:103)
==19724==    by 0x51371B: binary_log::Rotate_event::Rotate_event(char const*, unsigned int, binary_log::Format_description_event const*) (control_events.cpp:68)
==19724==    by 0x42438C: Rotate_log_event::Rotate_log_event(char const*, unsigned int, binary_log::Format_description_event const*) (log_event.cc:6305)
==19724==    by 0x41CCA4: Log_event::read_log_event(char const*, unsigned int, char const**, Format_description_log_event const*, char) (log_event.cc:1555)
==19724==    by 0x412D48: dump_remote_log_entries(st_print_event_info*, char const*) (mysqlbinlog.cc:2603)
==19724==    by 0x411FA8: dump_single_log(st_print_event_info*, char const*) (mysqlbinlog.cc:2234)
==19724==    by 0x412160: dump_multiple_logs(int, char**) (mysqlbinlog.cc:2274)
==19724==    by 0x414686: main (mysqlbinlog.cc:3336)
==19724== 
==19724== 564 (464 direct, 100 indirect) bytes in 2 blocks are definitely lost in loss record 20 of 20
==19724==    at 0x4C2745D: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==19724==    by 0x48AF32: my_raw_malloc (my_malloc.c:191)
==19724==    by 0x48AB32: my_malloc (my_malloc.c:54)
==19724==    by 0x41C145: Log_event::operator new(unsigned long) (log_event.cc:737)
==19724==    by 0x41CC8B: Log_event::read_log_event(char const*, unsigned int, char const**, Format_description_log_event const*, char) (log_event.cc:1555)
==19724==    by 0x412D48: dump_remote_log_entries(st_print_event_info*, char const*) (mysqlbinlog.cc:2603)
==19724==    by 0x411FA8: dump_single_log(st_print_event_info*, char const*) (mysqlbinlog.cc:2234)
==19724==    by 0x412160: dump_multiple_logs(int, char**) (mysqlbinlog.cc:2274)
==19724==    by 0x414686: main (mysqlbinlog.cc:3336)
==19724== 
mysqltest: In included file ./include/mysqlbinlog.inc at line 31:
included from /export-b/home/didrik/gitclone/trunk-mtr-valgrind/mysql-test/t/mysqlbinlog.test at line 84:
At line 30: command "$MYSQL_BINLOG --ssl $mysqlbinlog_parameters $mysqlbinlog_pipe" failed

How to repeat:
In current trunk:
./mtr --mem --valgrind-clients main.mysqlbinlog
[26 Oct 2015 16:28] Erlend Dahl
Bug#78966 was marked as a duplicate.
[16 Mar 2016 6:36] Erlend Dahl
Posted by developer:
 
This has a public duplicate (Bug#78966) and should be documented in the changelog.
[16 Mar 2016 6:36] Erlend Dahl
Posted by developer:
 
This has a public duplicate (Bug#78966) and should be documented in the changelog.
[21 Apr 2016 16:21] David Moss
Thanks for your feedback, this has been fixed and the following was added to the 5.7.12 changelog:

Valgrind tests of mysqlbinlog revealed some memory leaks.