Bug #92131 ASan: Direct leak of 272 byte(s) in main.mysqlpump_partial_bkp MTR test case
Submitted: 22 Aug 15:56 Modified: 30 Nov 17:51
Reporter: Yura Sorokin (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S3 (Non-critical)
Version:5.7.23 OS:Any
Assigned to: CPU Architecture:Any

[22 Aug 15:56] Yura Sorokin
Description:
The following memory errors are generated when 'main.mysqlpump_partial_bkp' MTR test case is run under Address Sanitizer on Ubuntu Bionic (GCC 7.3.0)

***********************************************************
main.mysqlpump_partial_bkp               [ fail ]
        Test ended at 2018-08-22 17:36:38

CURRENT_TEST: main.mysqlpump_partial_bkp
Dump completed in 1773 milliseconds
Dump completed in 1491 milliseconds
mysqlpump: [ERROR] (1) A partial dump from a server that is using GTID-based replication requires the --set-gtid-purged=[ON|OFF] option to be specified. Use ON if the intention is to deploy a new replication slave using only some of the data from the dumped server. Use OFF if the intention is to repair a table by copying it within a topology, and use OFF if the intention is to copy a table between replication topologies that are disjoint and will remain so.

Dump process encountered error and will not continue.

=================================================================
==73076==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 272 byte(s) in 2 object(s) allocated from:
    #0 0x7fea402b3458 in operator new(unsigned long) (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xe0458)
    #1 0x5575fc705965 in Mysql::Tools::Dump::Mysql_crawler::enumerate_objects() /mnt/hgfs/repos/percona-server/client/dump/mysql_crawler.cc:101
    #2 0x5575fc6ee786 in Mysql::Tools::Dump::Program::execute(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >) /mnt/hgfs/repos/percona-server/client/dump/program.cc:201
    #3 0x5575fc7f2c1c in Mysql::Tools::Base::Abstract_program::run(int, char**) /mnt/hgfs/repos/percona-server/client/base/abstract_program.cc:98
    #4 0x5575fc6ebd63 in main /mnt/hgfs/repos/percona-server/client/dump/program.cc:277
    #5 0x7fea3eb3bb96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)

Indirect leak of 200719 byte(s) in 195 object(s) allocated from:
    #0 0x7fea402b3458 in operator new(unsigned long) (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xe0458)
    #1 0x7fea3f24bdbe in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_mutate(unsigned long, unsigned long, char const*, unsigned long) (/usr/lib/x86_64-linux-gnu/libstdc++.so.6+0x128dbe)

Indirect leak of 153896 byte(s) in 31 object(s) allocated from:
    #0 0x7fea402b3458 in operator new(unsigned long) (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xe0458)
    #1 0x5575fc6f1a8c in void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char*>(char*, char*, std::forward_iterator_tag) /usr/include/c++/7/bits/basic_string.tcc:219
    #2 0x5575fc7a6c8e in void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct_aux<char*>(char*, char*, std::__false_type) /usr/include/c++/7/bits/basic_string.h:236
    #3 0x5575fc7a6c8e in void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char*>(char*, char*) /usr/include/c++/7/bits/basic_string.h:255
    #4 0x5575fc7a6c8e in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /usr/include/c++/7/bits/basic_string.h:440
    #5 0x5575fc7a6c8e in Mysql::Tools::Dump::Abstract_plain_sql_object::Abstract_plain_sql_object(unsigned long long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /mnt/hgfs/repos/percona-server/client/dump/abstract_plain_sql_object.cc:36
    #6 0x5575fc7a6e28 in Mysql::Tools::Dump::Abstract_plain_sql_object_dump_task::Abstract_plain_sql_object_dump_task(unsigned long long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /mnt/hgfs/repos/percona-server/client/dump/abstract_plain_sql_object_dump_task.cc:26
    #7 0x5575fc7878aa in Mysql::Tools::Dump::Stored_procedure::Stored_procedure(unsigned long long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /mnt/hgfs/repos/percona-server/client/dump/stored_procedure.cc:25
    #8 0x5575fc70c933 in void Mysql::Tools::Dump::Mysql_crawler::enumerate_functions<Mysql::Tools::Dump::Stored_procedure>(Mysql::Tools::Dump::Database const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) /mnt/hgfs/repos/percona-server/client/dump/mysql_crawler.cc:310
    #9 0x5575fc6fe683 in Mysql::Tools::Dump::Mysql_crawler::enumerate_database_objects(Mysql::Tools::Dump::Database const&) /mnt/hgfs/repos/percona-server/client/dump/mysql_crawler.cc:145
    #10 0x5575fc705cdd in Mysql::Tools::Dump::Mysql_crawler::enumerate_objects() /mnt/hgfs/repos/percona-server/client/dump/mysql_crawler.cc:110
    #11 0x5575fc6ee786 in Mysql::Tools::Dump::Program::execute(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >) /mnt/hgfs/repos/percona-server/client/dump/program.cc:201
    #12 0x5575fc7f2c1c in Mysql::Tools::Base::Abstract_program::run(int, char**) /mnt/hgfs/repos/percona-server/client/base/abstract_program.cc:98
    #13 0x5575fc6ebd63 in main /mnt/hgfs/repos/percona-server/client/dump/program.cc:277
    #14 0x7fea3eb3bb96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)

...

SUMMARY: AddressSanitizer: 1135041 byte(s) leaked in 6027 allocation(s).
mysqltest: At line 38: command "$MYSQL_PUMP --databases bug26199978 --set-gtid-purged=AUTO > $MYSQLTEST_VARDIR/tmp/bug26199978_auto.sql" failed with wrong error: 42
**************************************************************************

How to repeat:
Compile MySQL Server with ASan enabled
cmake . -DWITH_ASAN=ON -DWITH_ASAN_SCOPE=ON ...

run
./mysql-test/mtr --debug-server main.mysqlpump_partial_bkp
[22 Aug 19:22] Miguel Solorzano
Thank you for the bug report.
[30 Nov 17:51] Paul Dubois
Fixed in 5.7.25, 8.0.14.

mysqlpump did not free all allocated resources when it encountered an
error, resulting in memory leaks.