ASAN: MEMORY LEAK IN MYSQLDUMP

Bug #1587873 reported by Laurynas Biveinis on 2016-06-01
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

main.ddl_i18n_koi8r [ fail ]
        Test ended at 2016-06-01 15:38:37

CURRENT_TEST: main.ddl_i18n_koi8r

=================================================================
==5325==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 1024 byte(s) in 1 object(s) allocated from:
    #0 0x7f188cd0054a in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x9854a)
    #1 0x4796b4 in my_malloc /home/laurynas/mysql-server/mysys/my_malloc.c:38
    #2 0x473bc6 in init_dynamic_string /home/laurynas/mysql-server/mysys/string.c:39
    #3 0x406060 in init_dynamic_string_checked /home/laurynas/mysql-server/client/mysqldump.c:5430
    #4 0x4081a1 in init_dumping /home/laurynas/mysql-server/client/mysqldump.c:4283
    #5 0x410361 in dump_all_tables_in_db /home/laurynas/mysql-server/client/mysqldump.c:4310
    #6 0x412d58 in dump_databases /home/laurynas/mysql-server/client/mysqldump.c:4168
    #7 0x412d58 in main /home/laurynas/mysql-server/client/mysqldump.c:5583
    #8 0x7f188c19582f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)

Direct leak of 168 byte(s) in 1 object(s) allocated from:
    #0 0x7f188cd0054a in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x9854a)
    #1 0x4796b4 in my_malloc /home/laurynas/mysql-server/mysys/my_malloc.c:38
    #2 0x421201 in mysql_store_result /home/laurynas/mysql-server/sql-common/client.c:3984
    #3 0x404dc1 in mysql_query_with_error_report /home/laurynas/mysql-server/client/mysqldump.c:1097
    #4 0x40b456 in get_view_structure /home/laurynas/mysql-server/client/mysqldump.c:5253
    #5 0x40bf93 in dump_all_views_in_db /home/laurynas/mysql-server/client/mysqldump.c:4484
    #6 0x412da0 in dump_databases /home/laurynas/mysql-server/client/mysqldump.c:4175
    #7 0x412da0 in main /home/laurynas/mysql-server/client/mysqldump.c:5583
    #8 0x7f188c19582f 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 0x7f188cd0054a in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x9854a)
    #1 0x4796b4 in my_malloc /home/laurynas/mysql-server/mysys/my_malloc.c:38
    #2 0x4677ea in alloc_root /home/laurynas/mysql-server/mysys/my_alloc.c:217
    #3 0x418b05 in cli_read_rows /home/laurynas/mysql-server/sql-common/client.c:1609
    #4 0x421351 in mysql_store_result /home/laurynas/mysql-server/sql-common/client.c:3996
    #5 0x404dc1 in mysql_query_with_error_report /home/laurynas/mysql-server/client/mysqldump.c:1097
    #6 0x40b456 in get_view_structure /home/laurynas/mysql-server/client/mysqldump.c:5253
    #7 0x40bf93 in dump_all_views_in_db /home/laurynas/mysql-server/client/mysqldump.c:4484
    #8 0x412da0 in dump_databases /home/laurynas/mysql-server/client/mysqldump.c:4175
    #9 0x412da0 in main /home/laurynas/mysql-server/client/mysqldump.c:5583
    #10 0x7f188c19582f 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 0x7f188cd0054a in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x9854a)
    #1 0x4796b4 in my_malloc /home/laurynas/mysql-server/mysys/my_malloc.c:38
    #2 0x4677ea in alloc_root /home/laurynas/mysql-server/mysys/my_alloc.c:217
    #3 0x41a8e3 in unpack_fields /home/laurynas/mysql-server/sql-common/client.c:1463
    #4 0x41c0c6 in cli_read_query_result /home/laurynas/mysql-server/sql-common/client.c:3928
    #5 0x41e99c in mysql_real_query /home/laurynas/mysql-server/sql-common/client.c:3962
    #6 0x42c1bd in mysql_query /home/laurynas/mysql-server/libmysql/libmysql.c:704
    #7 0x404dae in mysql_query_with_error_report /home/laurynas/mysql-server/client/mysqldump.c:1096
    #8 0x40b456 in get_view_structure /home/laurynas/mysql-server/client/mysqldump.c:5253
    #9 0x40bf93 in dump_all_views_in_db /home/laurynas/mysql-server/client/mysqldump.c:4484
    #10 0x412da0 in dump_databases /home/laurynas/mysql-server/client/mysqldump.c:4175
    #11 0x412da0 in main /home/laurynas/mysql-server/client/mysqldump.c:5583
    #12 0x7f188c19582f 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 0x7f188cd0054a in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x9854a)
    #1 0x4796b4 in my_malloc /home/laurynas/mysql-server/mysys/my_malloc.c:38
    #2 0x418998 in cli_read_rows /home/laurynas/mysql-server/sql-common/client.c:1586
    #3 0x421351 in mysql_store_result /home/laurynas/mysql-server/sql-common/client.c:3996
    #4 0x404dc1 in mysql_query_with_error_report /home/laurynas/mysql-server/client/mysqldump.c:1097
    #5 0x40b456 in get_view_structure /home/laurynas/mysql-server/client/mysqldump.c:5253
    #6 0x40bf93 in dump_all_views_in_db /home/laurynas/mysql-server/client/mysqldump.c:4484
    #7 0x412da0 in dump_databases /home/laurynas/mysql-server/client/mysqldump.c:4175
    #8 0x412da0 in main /home/laurynas/mysql-server/client/mysqldump.c:5583
    #9 0x7f188c19582f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)

SUMMARY: AddressSanitizer: 17608 byte(s) leaked in 5 allocation(s).
mysqltest: At line 151: command "$MYSQL_DUMP --character-sets-dir=$MYSQL_SHAREDIR/charsets --databases mysqltest1 > $views_dump1" failed

The fix is to backport

commit 353dbcee4a27b8cfbbd127a28a043bdda764dcf1
Author: Jon Olav Hauglid <email address hidden>
Date: Fri Jun 12 14:55:35 2015 +0200

    Bug#21246627: ASAN: MEMORY LEAK IN PROCESS_SET_GTID_PURGED()
    Bug#21250584: ASAN: MEMORY LEAK IN MYSQLDUMP

    Fix three different memory leaks in mysqldump:
    1) Remember to call dynstr_free() on DYNAMIC_STRING.
    2) Remember to call mysql_free_result() on MYSQL_RES.
    3) Remember to call my_free() on string allocated by alloc_query_str().

This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers