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

When we upgrade the mariadb from 10.3.13 to 10.3.36, we found memory leak in mysql_upgrade.

    XMLWordPrintable

Details

    Description

      When we upgrade the mariadb from 10.3.13 to 10.3.36, we found some memory leak in mysql_upgrade.
      We can reproduce this bug in the following way:

      1. download the code of mariadb-10.3.13, and create a file to compile this code. I put this compilation file in the attachment. Then we create a mysqld instance by this way:

      //  Run the build.sh file and specify the basedir
      $ sh build.sh  -d  /flash3/mariadb_data/mysql
       
      // Install dependencies
      $ make install
       
      // initialization
      $ /flash3/mariadb_10_3_13/scripts/mysql_install_db --basedir='/flash3/mariadb_data/mysql' --datadir='/flash3/mariadb_data/data'
       
      // Create an instance using port 1235
      $ /flash3/mariadb_10_3_13/sql/mysqld --basedir=/flash3/mariadb_data/mysql --datadir=/flash3/mariadb_data/data --port=1235 --socket=/flash3/mariadb_data/mysql/mysql.sock&
       
      // Connect into a mysqld instance by root
      $ mysql -h127.0.0.1 -P1234 -uroot
      

      2. Create some tables on the Mariadb-10.3.13 instance

      MariaDB> create database test_1;
      MariaDB> use test_1;
      MariaDB> create table t(a int);
      MariaDB> insert into t values(1),(2);
      MariaDB> shutdown;
      

      3. Compile the code of mariadb-10.3.36 and create an instance in the same data directory with mariadb-10.3.13.

      // Compile the code of mariadb-10.3.36 by using the build.sh file.
      $ sh build.sh
       
      // Create an instance in the same directory with mariadb-10.3.13. And use the port 1246.
      $ flash3/mariadb_10_3_36/sql/mysqld --basedir=/flash3/mariadb_data/mysql --datadir=/flash3/mariadb_data/data --port=1246 --socket=/flash3/mariadb_data/mysql/mysql.sock&
      
      

      4. Run the mysql_upgrade of mariadb-10.3.36

      $ /flash3/mariadb_10_3_36/client/mysql_upgrade -uroot -p -S /flash3/mariadb_data/mysql/mysql.sock
      

      Now the warning appears:

      Phase 1/7: Checking and upgrading mysql database
      Processing databases
      mysql
      mysql.column_stats                                 OK
      mysql.columns_priv                                 OK
      mysql.db                                           OK
      mysql.event                                        OK
      mysql.func                                         OK
      mysql.gtid_slave_pos                               OK
      mysql.help_category                                OK
      mysql.help_keyword                                 OK
      mysql.help_relation                                OK
      mysql.help_topic                                   OK
      mysql.host                                         OK
      mysql.index_stats                                  OK
      mysql.innodb_index_stats                           OK
      mysql.innodb_table_stats                           OK
      mysql.plugin                                       OK
      mysql.proc                                         OK
      mysql.procs_priv                                   OK
      mysql.proxies_priv                                 OK
      mysql.roles_mapping                                OK
      mysql.servers                                      OK
      mysql.table_stats                                  OK
      mysql.tables_priv                                  OK
      mysql.time_zone                                    OK
      mysql.time_zone_leap_second                        OK
      mysql.time_zone_name                               OK
      mysql.time_zone_transition                         OK
      mysql.time_zone_transition_type                    OK
      mysql.transaction_registry                         OK
      mysql.user                                         OK
      Phase 2/7: Installing used storage engines... Skipped
      Phase 3/7: Fixing views
      Phase 4/7: Running 'mysql_fix_privilege_tables'
      Phase 5/7: Fixing table and database names
      Phase 6/7: Checking and upgrading tables
      Processing databases
      information_schema
      performance_schema
      test
      test_1
      test_1.t                                           OK
      Phase 7/7: Running 'FLUSH PRIVILEGES'
      OK
      Warning:    8 bytes lost at 0x7fb713508af0, allocated by T@0 at 0x7fb712b05b14, mysys/my_malloc.c:246, mysys/get_password.c:204, 0x7fb7111c1555, 0x7fb712ae3889
      Memory lost: 8 bytes in 1 chunks
      

      This problem maybe caused by a bug in mysql_upgrade.c line 1348 where malloc memory
      in get_tty_password() without free it.

      Attachments

        1. build.sh
          4 kB
          Linkang, Zhang

        Activity

          People

            Unassigned Unassigned
            Linkang, Zhang Linkang, Zhang
            Votes:
            0 Vote for this issue
            Watchers:
            5 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.