mysqlcheck memory leaks

Bug #1582741 reported by Laurynas Biveinis on 2016-05-17
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Percona Server moved to https://jira.percona.com/projects/PS
Status tracked in 5.7
5.5
Fix Released
Low
Laurynas Biveinis
5.6
Fix Released
Low
Laurynas Biveinis
5.7
Invalid
Undecided
Unassigned

Bug Description

On 5.5:

rpl.rpl_mysql_upgrade 'mix' w4 [ fail ]
        Test ended at 2016-05-12 08:24:49

CURRENT_TEST: rpl.rpl_mysql_upgrade
mysqltest: At line 27: command "$MYSQL_UPGRADE --skip-write-binlog --skip-verbose --force --user=root > $MYSQLTEST_VARDIR/log/mysql_upgrade.log 2>&1" failed

mysql_upgrade.log:

=================================================================
==1278==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 160 byte(s) in 1 object(s) allocated from:
    #0 0x7f573e51e54a in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x9854a)
    #1 0x46b4d5 in my_malloc /home/laurynas/mysql-server/mysys/my_malloc.c:38
    #2 0x4144f7 in mysql_store_result /home/laurynas/mysql-server/sql-common/client.c:3952
    #3 0x406206 in process_all_databases /home/laurynas/mysql-server/client/mysqlcheck.c:422
    #4 0x406206 in main /home/laurynas/mysql-server/client/mysqlcheck.c:957
    #5 0x7f573d9b382f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)

Indirect leak of 8160 byte(s) in 1 object(s) allocated from:
    #0 0x7f573e51e54a in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x9854a)
    #1 0x46b4d5 in my_malloc /home/laurynas/mysql-server/mysys/my_malloc.c:38
    #2 0x45a389 in alloc_root /home/laurynas/mysql-server/mysys/my_alloc.c:217
    #3 0x40bd99 in cli_read_rows /home/laurynas/mysql-server/sql-common/client.c:1609
    #4 0x414647 in mysql_store_result /home/laurynas/mysql-server/sql-common/client.c:3964
    #5 0x406206 in process_all_databases /home/laurynas/mysql-server/client/mysqlcheck.c:422
    #6 0x406206 in main /home/laurynas/mysql-server/client/mysqlcheck.c:957
    #7 0x7f573d9b382f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)

Indirect leak of 8160 byte(s) in 1 object(s) allocated from:
    #0 0x7f573e51e54a in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x9854a)
    #1 0x46b4d5 in my_malloc /home/laurynas/mysql-server/mysys/my_malloc.c:38
    #2 0x45a389 in alloc_root /home/laurynas/mysql-server/mysys/my_alloc.c:217
    #3 0x40db77 in unpack_fields /home/laurynas/mysql-server/sql-common/client.c:1463
    #4 0x40f35a in cli_read_query_result /home/laurynas/mysql-server/sql-common/client.c:3890
    #5 0x411c98 in mysql_real_query /home/laurynas/mysql-server/sql-common/client.c:3930
    #6 0x41f4b3 in mysql_query /home/laurynas/mysql-server/libmysql/libmysql.c:704
    #7 0x4061f6 in process_all_databases /home/laurynas/mysql-server/client/mysqlcheck.c:422
    #8 0x4061f6 in main /home/laurynas/mysql-server/client/mysqlcheck.c:957
    #9 0x7f573d9b382f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)

Indirect leak of 96 byte(s) in 1 object(s) allocated from:
    #0 0x7f573e51e54a in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x9854a)
    #1 0x46b4d5 in my_malloc /home/laurynas/mysql-server/mysys/my_malloc.c:38
    #2 0x40bc2c in cli_read_rows /home/laurynas/mysql-server/sql-common/client.c:1586
    #3 0x414647 in mysql_store_result /home/laurynas/mysql-server/sql-common/client.c:3964
    #4 0x406206 in process_all_databases /home/laurynas/mysql-server/client/mysqlcheck.c:422
    #5 0x406206 in main /home/laurynas/mysql-server/client/mysqlcheck.c:957
    #6 0x7f573d9b382f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)

SUMMARY: AddressSanitizer: 16576 byte(s) leaked in 4 allocation(s).

Fixed in 5.7 by

commit 6d76033a7070ff04d4287169df918e22e1275bb9
Author: Jon Olav Hauglid <email address hidden>
Date: Tue Jun 16 14:13:05 2015 +0100

    Bug#21246964: ASAN: MEMORY LEAK IN PROCESS_ALL_TABLES()
    Bug#21247377: ASAN: MEMORY LEAK IN SHOW_VARIABLE_QUERY_EXTRACTOR / RUN_SQL_FIX_PRIVILEGE_TABLES()
    Bug#21253535: ASAN: MEMORY LEAK IN MYSQL_UPGRADE

    Fix memory leak in mysqlcheck - process_all_tables().
    Close result by calling mysql_free_result() after processing.

    Fix memory leaks related to mysql_upgrade:
    1) Allocate Instance_callback instances on stack rather than heap.
    2) Always call mysql_close() to deallocate memory.

    Also fix a valgrind warning,
    Conditional jump or move depends on uninitialised value(s)
    in Mysql::Tools::Upgrade::Program::fix_privilage_tables_error()
    (sic)

tags: added: asan ci upstream

Percona now uses JIRA for bug reports so this bug report is migrated to: https://jira.percona.com/browse/PS-3439

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers