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

Memory leak with EXPLAIN UPDATE, crash in multi_update::initialize_tables

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Confirmed (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 10.0, 10.1, 10.2, 10.3, 10.4, 10.5, 10.6, 10.7
    • Fix Version/s: 10.2, 10.3, 10.4, 10.5, 10.6, 10.7
    • Component/s: Optimizer
    • Labels:
      None

      Description

      CREATE TABLE t1 ( i2 int, v2 varchar(1)) ;
      CREATE TABLE t2 ( i1 int, i2 int, v1 varchar(1)) ;
       
      EXPLAIN
      UPDATE t2 JOIN t1 ON (t2.v1 = t1.v2)
      SET t2.i1 = 1, t1.i2 = 1
      WHERE t2.i2 IN (SELECT 1 UNION SELECT 2);
      

      In 10.0-10.2

      mysqld: /home/alice/git/10.1/sql/sql_class.cc:1608: virtual THD::~THD(): Assertion `status_var.local_memory_used == 0' failed.
      mysqld: /home/alice/git/10.2/sql/sql_class.cc:1550: virtual THD::~THD(): Assertion `status_var.local_memory_used == 0 || !debug_assert_on_not_freed_memory' failed.
      

      Version: '10.3.9-MariaDB-debug-log'  socket: '/home/alice/git/10.3/mysql-test/var/tmp/mysqld.1.sock'  port: 16000  Source distribution
      ASAN:SIGSEGV
      =================================================================
      ==29499==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x5590f60b8a90 bp 0x7ffb07ec3e90 sp 0x7ffb07ec3c40 T5)
          #0 0x5590f60b8a8f in multi_update::initialize_tables(JOIN*) /home/alice/git/10.3/sql/sql_update.cc:2100
          #1 0x5590f5ef85ee in JOIN::optimize_stage2() /home/alice/git/10.3/sql/sql_select.cc:1952
          #2 0x5590f5ef7fa3 in JOIN::optimize_inner() /home/alice/git/10.3/sql/sql_select.cc:1907
          #3 0x5590f5ef3ea3 in JOIN::optimize() /home/alice/git/10.3/sql/sql_select.cc:1448
          #4 0x5590f5f0db32 in mysql_select(THD*, TABLE_LIST*, unsigned int, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*) /home/alice/git/10.3/sql/sql_select.cc:4206
          #5 0x5590f60a4ce2 in st_select_lex_unit::exec() /home/alice/git/10.3/sql/sql_union.cc:1592
          #6 0x5590f5f9ca09 in mysql_explain_union(THD*, st_select_lex_unit*, select_result*) /home/alice/git/10.3/sql/sql_select.cc:25705
          #7 0x5590f5f9c550 in select_describe /home/alice/git/10.3/sql/sql_select.cc:25675
          #8 0x5590f5f4a3bf in return_zero_rows /home/alice/git/10.3/sql/sql_select.cc:13231
          #9 0x5590f5f0c37d in JOIN::exec_inner() /home/alice/git/10.3/sql/sql_select.cc:3956
          #10 0x5590f5f0a951 in JOIN::exec() /home/alice/git/10.3/sql/sql_select.cc:3815
          #11 0x5590f5f0dd23 in mysql_select(THD*, TABLE_LIST*, unsigned int, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*) /home/alice/git/10.3/sql/sql_select.cc:4220
          #12 0x5590f60b575d in mysql_multi_update(THD*, TABLE_LIST*, List<Item>*, List<Item>*, Item*, unsigned long long, enum_duplicates, bool, st_select_lex_unit*, st_select_lex*, multi_update**) /home/alice/git/10.3/sql/sql_update.cc:1761
          #13 0x5590f5e61cab in mysql_execute_command(THD*) /home/alice/git/10.3/sql/sql_parse.cc:4635
          #14 0x5590f5e779c7 in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /home/alice/git/10.3/sql/sql_parse.cc:8073
          #15 0x5590f5e526ae in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /home/alice/git/10.3/sql/sql_parse.cc:1847
          #16 0x5590f5e4f846 in do_command(THD*) /home/alice/git/10.3/sql/sql_parse.cc:1392
          #17 0x5590f619eca1 in do_handle_one_connection(CONNECT*) /home/alice/git/10.3/sql/sql_connect.cc:1402
          #18 0x5590f619e67e in handle_one_connection /home/alice/git/10.3/sql/sql_connect.cc:1308
          #19 0x5590f74b61d4 in pfs_spawn_thread /home/alice/git/10.3/storage/perfschema/pfs.cc:1862
          #20 0x7ffb128216b9 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x76b9)
          #21 0x7ffb11cb641c in clone (/lib/x86_64-linux-gnu/libc.so.6+0x10741c)
      

      also crashes on non-debug build:

      210209 14:33:49 [ERROR] mysqld got signal 11 ;
      Server version: 10.5.9-MariaDB
       
      ??:0(__restore_rt)[0x7fecb3b0a730]
      sql/sql_update.cc:2296(multi_update::initialize_tables(JOIN*))[0x5592a77bdef4]
      sql/sql_select.cc:2329(JOIN::optimize_stage2())[0x5592a7769810]
      sql/sql_select.cc:2281(JOIN::optimize_inner())[0x5592a776d16b]
      sql/sql_select.cc:1629(JOIN::optimize())[0x5592a776f023]
      sql/sql_select.cc:4705(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*))[0x5592a776f0e7]
      sql/sql_union.cc:2360(st_select_lex_unit::exec())[0x5592a77b87e5]
      sql/sql_select.cc:27278(mysql_explain_union(THD*, st_select_lex_unit*, select_result*))[0x5592a776fda0]
      sql/sql_select.cc:27245(select_describe(JOIN*, bool, bool, bool, char const*) [clone .constprop.511])[0x5592a776feb5]
      sql/sql_select.cc:4428(JOIN::exec_inner())[0x5592a7770510]
      sql/sql_select.cc:4247(JOIN::exec())[0x5592a7770d70]
      sql/sql_select.cc:4721(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*))[0x5592a776f138]
      sql/sql_class.h:4061(mysql_multi_update(THD*, TABLE_LIST*, List<Item>*, List<Item>*, Item*, unsigned long long, enum_duplicates, bool, st_select_lex_unit*, st_select_lex*, multi_update**))[0x5592a77c1179]
      sql/sql_parse.cc:4530(mysql_execute_command(THD*))[0x5592a7719b91]
      sql/sql_parse.cc:8079(mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool))[0x5592a770be52]
      sql/sql_parse.cc:1892(dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool))[0x5592a7716ce2]
      sql/sql_parse.cc:1370(do_command(THD*))[0x5592a7717b9f]
      sql/sql_connect.cc:1410(do_handle_one_connection(CONNECT*, bool))[0x5592a7800170]
      sql/sql_connect.cc:1312(handle_one_connection)[0x5592a780054d]
      perfschema/pfs.cc:2204(pfs_spawn_thread)[0x5592a7b2e1bb]
      nptl/pthread_create.c:487(start_thread)[0x7fecb3afffa3]
      x86_64/clone.S:97(clone)[0x7fecb31084cf]
       
      Query (0x7fec5c011de0): EXPLAIN UPDATE t2 JOIN t1 ON (t2.v1 = t1.v2) SET t2.i1 = 1, t1.i2 = 1 WHERE t2.i2 IN (SELECT 1 UNION SELECT 2)
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              psergei Sergei Petrunia
              Reporter:
              alice Alice Sherepa
              Votes:
              1 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.