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

Memory leak in get_quick_select / TRP_RANGE::make_quick after INSERT .. RETURNING

    XMLWordPrintable

    Details

      Description

      CREATE TABLE t (a INT, KEY(a));
      INSERT INTO t VALUES (1),(2);
      INSERT INTO t WITH cte AS (SELECT a FROM t AS A WHERE a > 50 AND a <> RAND(0)) SELECT * FROM cte RETURNING *;
       
      --source include/restart_mysqld.inc
       
      # Cleanup
      DROP TABLE t;
      

      10.5 b546913b

      ==2617276==ERROR: LeakSanitizer: detected memory leaks
       
      Direct leak of 328 byte(s) in 1 object(s) allocated from:
          #0 0x7fec5e546647 in operator new(unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cpp:99
          #1 0x55efe1bbf724 in get_quick_select(PARAM*, unsigned int, SEL_ARG*, unsigned int, unsigned int, st_mem_root*) /data/src/10.5/sql/opt_range.cc:11785
          #2 0x55efe1bd74ab in TRP_RANGE::make_quick(PARAM*, bool, st_mem_root*) /data/src/10.5/sql/opt_range.cc:2270
          #3 0x55efe1bb0305 in SQL_SELECT::test_quick_select(THD*, Bitmap<64u>, unsigned long long, unsigned long long, bool, bool, bool, bool) /data/src/10.5/sql/opt_range.cc:3057
          #4 0x55efe1199da5 in get_quick_record_count /data/src/10.5/sql/sql_select.cc:4841
          #5 0x55efe1199da5 in make_join_statistics /data/src/10.5/sql/sql_select.cc:5568
          #6 0x55efe11ac617 in JOIN::optimize_inner() /data/src/10.5/sql/sql_select.cc:2313
          #7 0x55efe11ae61c in JOIN::optimize() /data/src/10.5/sql/sql_select.cc:1671
          #8 0x55efe0f52361 in mysql_derived_optimize /data/src/10.5/sql/sql_derived.cc:1048
          #9 0x55efe0f5080d in mysql_handle_single_derived(LEX*, TABLE_LIST*, unsigned int) /data/src/10.5/sql/sql_derived.cc:200
          #10 0x55efe11ac95b in JOIN::optimize_inner() /data/src/10.5/sql/sql_select.cc:2131
          #11 0x55efe11ae61c in JOIN::optimize() /data/src/10.5/sql/sql_select.cc:1671
          #12 0x55efe11ae899 in mysql_select(THD*, TABLE_LIST*, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*) /data/src/10.5/sql/sql_select.cc:4783
          #13 0x55efe11b153d in handle_select(THD*, LEX*, select_result*, unsigned long) /data/src/10.5/sql/sql_select.cc:444
          #14 0x55efe104e15f in mysql_execute_command(THD*) /data/src/10.5/sql/sql_parse.cc:4770
          #15 0x55efe105123b in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /data/src/10.5/sql/sql_parse.cc:8100
          #16 0x55efe1057554 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /data/src/10.5/sql/sql_parse.cc:1891
          #17 0x55efe105ce52 in do_command(THD*) /data/src/10.5/sql/sql_parse.cc:1375
          #18 0x55efe13bec5e in do_handle_one_connection(CONNECT*, bool) /data/src/10.5/sql/sql_connect.cc:1418
          #19 0x55efe13bf30c in handle_one_connection /data/src/10.5/sql/sql_connect.cc:1312
          #20 0x55efe1f0bcf4 in pfs_spawn_thread /data/src/10.5/storage/perfschema/pfs.cc:2201
          #21 0x7fec5dfb0ea6 in start_thread nptl/pthread_create.c:477
       
      Indirect leak of 4080 byte(s) in 1 object(s) allocated from:
          #0 0x7fec5e544e8f in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
          #1 0x55efe28bc748 in my_malloc /data/src/10.5/mysys/my_malloc.c:90
          #2 0x55efe28a8c1d in alloc_root /data/src/10.5/mysys/my_alloc.c:244
          #3 0x55efe1b7574f in Query_arena::alloc(unsigned long) /data/src/10.5/sql/sql_class.h:1171
          #4 0x55efe1b7574f in QUICK_RANGE_SELECT::QUICK_RANGE_SELECT(THD*, TABLE*, unsigned int, bool, st_mem_root*, bool*) /data/src/10.5/sql/opt_range.cc:1300
          #5 0x55efe1bbf7a3 in get_quick_select(PARAM*, unsigned int, SEL_ARG*, unsigned int, unsigned int, st_mem_root*) /data/src/10.5/sql/opt_range.cc:11785
          #6 0x55efe1bd74ab in TRP_RANGE::make_quick(PARAM*, bool, st_mem_root*) /data/src/10.5/sql/opt_range.cc:2270
          #7 0x55efe1bb0305 in SQL_SELECT::test_quick_select(THD*, Bitmap<64u>, unsigned long long, unsigned long long, bool, bool, bool, bool) /data/src/10.5/sql/opt_range.cc:3057
          #8 0x55efe1199da5 in get_quick_record_count /data/src/10.5/sql/sql_select.cc:4841
          #9 0x55efe1199da5 in make_join_statistics /data/src/10.5/sql/sql_select.cc:5568
          #10 0x55efe11ac617 in JOIN::optimize_inner() /data/src/10.5/sql/sql_select.cc:2313
          #11 0x55efe11ae61c in JOIN::optimize() /data/src/10.5/sql/sql_select.cc:1671
          #12 0x55efe0f52361 in mysql_derived_optimize /data/src/10.5/sql/sql_derived.cc:1048
          #13 0x55efe0f5080d in mysql_handle_single_derived(LEX*, TABLE_LIST*, unsigned int) /data/src/10.5/sql/sql_derived.cc:200
          #14 0x55efe11ac95b in JOIN::optimize_inner() /data/src/10.5/sql/sql_select.cc:2131
          #15 0x55efe11ae61c in JOIN::optimize() /data/src/10.5/sql/sql_select.cc:1671
          #16 0x55efe11ae899 in mysql_select(THD*, TABLE_LIST*, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*) /data/src/10.5/sql/sql_select.cc:4783
          #17 0x55efe11b153d in handle_select(THD*, LEX*, select_result*, unsigned long) /data/src/10.5/sql/sql_select.cc:444
          #18 0x55efe104e15f in mysql_execute_command(THD*) /data/src/10.5/sql/sql_parse.cc:4770
          #19 0x55efe105123b in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /data/src/10.5/sql/sql_parse.cc:8100
          #20 0x55efe1057554 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /data/src/10.5/sql/sql_parse.cc:1891
          #21 0x55efe105ce52 in do_command(THD*) /data/src/10.5/sql/sql_parse.cc:1375
          #22 0x55efe13bec5e in do_handle_one_connection(CONNECT*, bool) /data/src/10.5/sql/sql_connect.cc:1418
          #23 0x55efe13bf30c in handle_one_connection /data/src/10.5/sql/sql_connect.cc:1312
          #24 0x55efe1f0bcf4 in pfs_spawn_thread /data/src/10.5/storage/perfschema/pfs.cc:2201
          #25 0x7fec5dfb0ea6 in start_thread nptl/pthread_create.c:477
       
      SUMMARY: AddressSanitizer: 4408 byte(s) leaked in 2 allocation(s).
      

        Attachments

          Activity

            People

            Assignee:
            psergei Sergei Petrunia
            Reporter:
            elenst Elena Stepanova
            Votes:
            0 Vote for this issue
            Watchers:
            1 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.