Allocator/deallocator mismatch in User_var_log_event::print

Bug #1587757 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
Medium
Laurynas Biveinis
5.6
Invalid
Medium
Unassigned
5.7
Invalid
Medium
Unassigned

Bug Description

It shows up as an Address Sanitizer error on rpl_mdev382, binlog_stm_ctype_ucs mysqlbinlog user_var-binlog:

rpl.rpl_mdev382 'stmt' w4 [ fail ]
...
        Test ended at 2016-05-23 06:37:22

CURRENT_TEST: rpl.rpl_mdev382

=================================================================
==25558==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 203 byte(s) in 1 object(s) allocated from:
    #0 0x7f40cb9c054a in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x9854a)
    #1 0x49798b in my_malloc /mnt/workspace/percona-server-5.5-asan-param/BUILD_TYPE/debug-asan/Host/ubuntu-xenial-64bit/mysys/my_malloc.c:38
    #2 0x417ea1 in User_var_log_event::print(_IO_FILE*, st_print_event_info*) /mnt/workspace/percona-server-5.5-asan-param/BUILD_TYPE/debug-asan/Host/ubuntu-xenial-64bit/sql/log_event.cc:6162
    #3 0x42d4a1 in process_event(st_print_event_info*, Log_event*, unsigned long long, char const*) /mnt/workspace/percona-server-5.5-asan-param/BUILD_TYPE/debug-asan/Host/ubuntu-xenial-64bit/client/mysqlbinlog.cc:1129
    #4 0x42f52d in dump_local_log_entries /mnt/workspace/percona-server-5.5-asan-param/BUILD_TYPE/debug-asan/Host/ubuntu-xenial-64bit/client/mysqlbinlog.cc:2265
    #5 0x42f52d in dump_log_entries /mnt/workspace/percona-server-5.5-asan-param/BUILD_TYPE/debug-asan/Host/ubuntu-xenial-64bit/client/mysqlbinlog.cc:1700
    #6 0x42fc89 in main /mnt/workspace/percona-server-5.5-asan-param/BUILD_TYPE/debug-asan/Host/ubuntu-xenial-64bit/client/mysqlbinlog.cc:2371
    #7 0x7f40ca1f582f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)

SUMMARY: AddressSanitizer: 203 byte(s) leaked in 1 allocation(s).
mysqltest: At line 171: command "$MYSQL_BINLOG --short-form --start-position=$binlog_start --stop-position=$pos2 $MYSQLD_DATADIR/master-bin.000001" failed

This is caused by

void User_var_log_event::print(FILE* file, PRINT_EVENT_INFO* print_event_info)
{
...
      hex_str= (char *)my_malloc(2*val_len+1+2,MYF(MY_WME)); // 2 hex digits / byte
...
      my_afree(hex_str);
...
}

my_afree should be my_free. This bug is a Percona merge regresion.

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

Other bug subscribers