Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-31636

Memory leak in Sys_var_gtid_binlog_state::do_check()

    XMLWordPrintable

Details

    Description

      --source include/have_log_bin.inc
      RESET MASTER;
      --error ER_WRONG_VALUE_FOR_VAR
      SET
        @@global.gtid_binlog_state='1-1-101,2-1-2002',
        @@global.slave_parallel_mode=x;
      SELECT @@global.gtid_binlog_state;
      

      ***Warnings generated in error logs during shutdown after running tests: main.AAA
       
      Warning: Memory not freed: 224
      Warning:   40 bytes lost at 0x45fa260, allocated by T@0 at sql/sys_vars.cc:2120, sql/set_var.cc:246, sql/set_var.cc:810, sql/set_var.cc:738, sql/sql_parse.cc:5040, sql/sql_parse.cc:8023, sql/sql_parse.cc:1896, sql/sql_parse.cc:1407
      Warning:  184 bytes lost at 0x7f71481b7790, allocated by T@0 at mysys/my_malloc.c:143, sql/rpl_gtid.cc:1359, sql/sys_vars.cc:2114, sql/set_var.cc:246, sql/set_var.cc:810, sql/set_var.cc:738, sql/sql_parse.cc:5040, sql/sql_parse.cc:8023
      Warning:  152 bytes lost at 0x409c760, allocated by T@0 at mysys/array.c:73, mysys/hash.c:99, sql/sql_hset.h:37, sql/debug_sync.cc:90, sql/debug_sync.cc:166, sql/debug_sync.cc:1808, ??:0, csu/libc-start.c:268
      Warning:   40 bytes lost at 0x45fa260, allocated by T@0 at sql/sys_vars.cc:2120, sql/set_var.cc:246, sql/set_var.cc:810, sql/set_var.cc:738, sql/sql_parse.cc:5040, sql/sql_parse.cc:8023, sql/sql_parse.cc:1896, sql/sql_parse.cc:1407
      Warning:  184 bytes lost at 0x7f71481b7790, allocated by T@0 at mysys/my_malloc.c:143, sql/rpl_gtid.cc:1359, sql/sys_vars.cc:2114, sql/set_var.cc:246, sql/set_var.cc:810, sql/set_var.cc:738, sql/sql_parse.cc:5040, sql/sql_parse.cc:8023
      

      The leaked memory is allocated in Sys_var_gtid_binlog_state::do_check() in this code:

        if (!(data= (gtid_binlog_state_data *)my_malloc(PSI_INSTRUMENT_ME,
                                                        sizeof(*data), MYF(0))))
        {
      
      

      The problem happens because:

      • The @@global.gtid_binlog_state='1-1-101,2-1-2002' part of the statement allocated memory and assigns it to var->save_result.ptr
      • The @@global.slave_parallel_mode=x part fails on an error (wrong value)
      • The entire statement fails
      • The allocated value in var->save_result.ptr is never freed during the statement cleanup

      Attachments

        Activity

          People

            bnestere Brandon Nesterenko
            bar Alexander Barkov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.