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

SIGSEGV in Bitmap<64u>::merge on SELECT

    XMLWordPrintable

    Details

      Description

      Very similar to MDEV-28509, however in this case only 10.4+ crashes, and the stack is a bit different.

      CREATE TABLE c(c INT) ENGINE=InnoDB;
      SELECT * FROM c AS c WHERE c=c + 0 / 0 WINDOW c AS(ORDER BY (SELECT * FROM c GROUP BY c HAVING c=- 0 OR c>0 AND NOT c<c WINDOW c AS(PARTITION BY c)));
      

      Leads to:

      10.10.0 081a284712bb661349e2e3802077b12211cede3e (Debug)

      Core was generated by `/test/MD310522-mariadb-10.10.0-linux-x86_64-dbg/bin/mysqld --no-defaults --core'.
      Program terminated with signal SIGSEGV, Segmentation fault.
      #0  Bitmap<64u>::merge (map2=..., this=<optimized out>)
          at /test/10.10_dbg/sql/sql_bitmap.h:210
      [Current thread is 1 (Thread 0x153cf77fb700 (LWP 3568523))]
      (gdb) bt
      #0  Bitmap<64u>::merge (map2=<optimized out>, this=<optimized out>) at /test/10.10_dbg/sql/sql_bitmap.h:210
      #1  add_key_field (join=join@entry=0x153cdc0255a0, key_fields=key_fields@entry=0x153cf77f9408, and_level=1, cond=cond@entry=0x153cdc026860, field=0x153cdc029d48, eq_func=eq_func@entry=true, value=0x153cf77f92e0, num_values=1, usable_tables=18446744073709551615, sargables=0x153cf77f9528, row_col_no=0) at /test/10.10_dbg/sql/sql_select.cc:6304
      #2  0x00005558293a2ed9 in Item_equal::add_key_fields (this=0x153cdc026860, join=0x153cdc0255a0, key_fields=0x153cf77f9408, and_level=0x153cf77f9404, usable_tables=18446744073709551615, sargables=0x153cf77f9528) at /test/10.10_dbg/sql/sql_select.cc:6749
      #3  0x00005558293a2354 in Item_cond::add_key_fields (this=<optimized out>, join=0x153cdc0255a0, key_fields=0x153cf77f9408, and_level=0x153cf77f9404, usable_tables=18446744073709551615, sargables=0x153cf77f9528) at /test/10.10_dbg/sql/sql_list.h:443
      #4  0x00005558293a32a8 in update_ref_and_keys (thd=thd@entry=0x153cdc000db8, keyuse=keyuse@entry=0x153cdc0258c0, join_tab=0x153cdc0269c8, tables=1, cond=0x153cdc016e98, normal_tables=normal_tables@entry=18446744073709551615, select_lex=0x153cdc015188, sargables=0x153cf77f9528) at /test/10.10_dbg/sql/sql_select.cc:7178
      #5  0x00005558293d9668 in make_join_statistics (join=join@entry=0x153cdc0255a0, tables_list=@0x153cdc0153a0: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x153cdc025b58, last = 0x153cdc025b58, elements = 1}, <No data fields>}, keyuse_array=keyuse_array@entry=0x153cdc0258c0) at /test/10.10_dbg/sql/sql_select.cc:5430
      #6  0x00005558293e2012 in JOIN::optimize_inner (this=this@entry=0x153cdc0255a0) at /test/10.10_dbg/sql/sql_select.cc:2503
      #7  0x00005558293e2452 in JOIN::optimize (this=this@entry=0x153cdc0255a0) at /test/10.10_dbg/sql/sql_select.cc:1845
      #8  0x0000555829326a24 in st_select_lex::optimize_unflattened_subqueries (this=0x153cdc013db8, const_only=const_only@entry=true) at /test/10.10_dbg/sql/sql_lex.cc:4916
      #9  0x00005558295156a1 in JOIN::optimize_constant_subqueries (this=this@entry=0x153cdc024ad8) at /test/10.10_dbg/sql/opt_subselect.cc:5622
      #10 0x00005558293e0f76 in JOIN::optimize_inner (this=this@entry=0x153cdc024ad8) at /test/10.10_dbg/sql/sql_select.cc:2165
      #11 0x00005558293e2452 in JOIN::optimize (this=this@entry=0x153cdc024ad8) at /test/10.10_dbg/sql/sql_select.cc:1845
      #12 0x00005558293e2545 in mysql_select (thd=thd@entry=0x153cdc000db8, tables=0x153cdc0143a0, fields=@0x153cdc014058: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x153cdc014348, last = 0x153cdc014348, elements = 1}, <No data fields>}, conds=0x153cdc014f48, og_num=1, order=0x0, group=0x153cdc015f80, having=0x0, proc_param=0x0, select_options=2147748608, result=0x153cdc024ab0, unit=0x153cdc004fd8, select_lex=0x153cdc013db8) at /test/10.10_dbg/sql/sql_select.cc:5030
      #13 0x00005558293e2d8e in handle_select (thd=thd@entry=0x153cdc000db8, lex=lex@entry=0x153cdc004f00, result=result@entry=0x153cdc024ab0, setup_tables_done_option=setup_tables_done_option@entry=0) at /test/10.10_dbg/sql/sql_select.cc:578
      #14 0x000055582934eb5e in execute_sqlcom_select (thd=thd@entry=0x153cdc000db8, all_tables=0x153cdc0143a0) at /test/10.10_dbg/sql/sql_parse.cc:6260
      #15 0x000055582935ae70 in mysql_execute_command (thd=thd@entry=0x153cdc000db8, is_called_from_prepared_stmt=is_called_from_prepared_stmt@entry=false) at /test/10.10_dbg/sql/sql_parse.cc:3944
      #16 0x0000555829348e3a in mysql_parse (thd=thd@entry=0x153cdc000db8, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x153cf77fa470) at /test/10.10_dbg/sql/sql_parse.cc:8036
      #17 0x0000555829356422 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x153cdc000db8, packet=packet@entry=0x153cdc00b6d9 "SELECT * FROM c AS c WHERE c=c + 0 / 0 WINDOW c AS(ORDER BY (SELECT * FROM c GROUP BY c HAVING c=- 0 OR c>0 AND NOT c<c WINDOW c AS(PARTITION BY c)))", packet_length=packet_length@entry=149, blocking=blocking@entry=true) at /test/10.10_dbg/sql/sql_class.h:1364
      #18 0x0000555829358b2c in do_command (thd=0x153cdc000db8, blocking=blocking@entry=true) at /test/10.10_dbg/sql/sql_parse.cc:1407
      #19 0x00005558294b83c0 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x55582c89dfb8, put_in_cache=put_in_cache@entry=true) at /test/10.10_dbg/sql/sql_connect.cc:1418
      #20 0x00005558294b88c9 in handle_one_connection (arg=0x55582c89dfb8) at /test/10.10_dbg/sql/sql_connect.cc:1312
      #21 0x0000153d30286609 in start_thread (arg=<optimized out>) at pthread_create.c:477
      #22 0x0000153d2fe72133 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
      

      Bug confirmed present in:
      MariaDB: 10.4.26 (dbg), 10.4.26 (opt), 10.5.17 (dbg), 10.5.17 (opt), 10.6.9 (dbg), 10.6.9 (opt), 10.7.5 (dbg), 10.7.5 (opt), 10.8.4 (dbg), 10.8.4 (opt), 10.9.2 (dbg), 10.9.2 (opt), 10.10.0 (dbg), 10.10.0 (opt)

      Bug (or feature/syntax) confirmed not present in:
      MariaDB: 10.3.36 (dbg), 10.3.36 (opt)
      MySQL: 5.5.62 (dbg), 5.5.62 (opt), 5.6.51 (dbg), 5.6.51 (opt), 5.7.38 (dbg), 5.7.38 (opt), 8.0.29 (dbg), 8.0.29 (opt)

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              psergei Sergei Petrunia
              Reporter:
              Roel Roel Van de Paar
              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.