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

Assertion `field->table == table' failed in Create_tmp_table::finalize and create_tmp_table and SIGSEGV in hp_rec_hashnr

    XMLWordPrintable

Details

    Description

      Whilst reducing the testcase for MDEV-28501, I discovered another bug. Testcase can likely be improved further later. Possibly connected with MDEV-25490.

      CREATE TABLE t(v817 TEXT) ENGINE=InnoDB;
      SELECT v817 / 1.0 AS v818 FROM (SELECT DISTINCT 42 FROM (SELECT DISTINCT v817 FROM t)AS v819,t AS v820,t AS v821,t AS v822 JOIN t) AS v823 NATURAL JOIN t AS v824 NATURAL JOIN t WINDOW v832 AS (PARTITION BY (v817 OR NOT v817) BETWEEN (((NOT (((v817='')) * NULL)))) AND 1.0 ORDER BY''BETWEEN (((SELECT v817 FROM t GROUP BY v817 WINDOW v833 AS (PARTITION BY v817 ORDER BY  1  DESC RANGE BETWEEN 1.0 FOLLOWING AND 1.0 FOLLOWING) ORDER BY v817 + v817,v817 + v817)=3)) AND (CASE v817 WHEN (v817 IN (0,0,11,0 / v817=v817 + CASE v817 WHEN TRUE THEN 128 ELSE 99 END OR v817=v817 OR v817=v817)) THEN 2 ELSE 2147483647 END=128));
      

      Leads to:

      10.9.0 0b14dbd45b5a1c02616d611876158d44b92b77bf (Debug)

      mysqld: /test/10.9_dbg/sql/sql_select.cc:19379: bool Create_tmp_table::finalize(THD*, TABLE*, TMP_TABLE_PARAM*, bool, bool): Assertion `field->table == table' failed.
      

      10.9.0 0b14dbd45b5a1c02616d611876158d44b92b77bf (Debug)

      Core was generated by `/test/MD030522-mariadb-10.9.0-linux-x86_64-dbg/bin/mysqld --no-defaults --core-'.
      Program terminated with signal SIGABRT, Aborted.
      #0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
      [Current thread is 1 (Thread 0x148f4812d700 (LWP 1977878))]
      (gdb) bt
      #0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
      #1  0x0000148f6e2e4859 in __GI_abort () at abort.c:79
      #2  0x0000148f6e2e4729 in __assert_fail_base (fmt=0x148f6e47a588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x55ae21f244b1 "field->table == table", file=0x55ae21f3fcb8 "/test/10.9_dbg/sql/sql_select.cc", line=19379, function=<optimized out>) at assert.c:92
      #3  0x0000148f6e2f6006 in __GI___assert_fail (assertion=assertion@entry=0x55ae21f244b1 "field->table == table", file=file@entry=0x55ae21f3fcb8 "/test/10.9_dbg/sql/sql_select.cc", line=line@entry=19379, function=function@entry=0x55ae21f41b08 "bool Create_tmp_table::finalize(THD*, TABLE*, TMP_TABLE_PARAM*, bool, bool)") at assert.c:101
      #4  0x000055ae213b4e68 in Create_tmp_table::finalize (this=this@entry=0x148f4812b5c0, thd=thd@entry=0x148ebc000db8, table=table@entry=0x148ebc0a2be0, param=param@entry=0x148ebc09e5c8, do_not_open=do_not_open@entry=true, keep_row_order=keep_row_order@entry=false) at /test/10.9_dbg/sql/sql_select.cc:19379
      #5  0x000055ae213b54e8 in create_tmp_table (thd=0x148ebc000db8, param=0x148ebc09e5c8, fields=@0x148ebc032cc8: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x148ebc08a7c8, last = 0x148ebc014838, elements = 4}, <No data fields>}, group=group@entry=0x148ebc02e3e0, distinct=distinct@entry=false, save_sum_fields=save_sum_fields@entry=false, select_options=2147748608, rows_limit=18446744073709551615, table_alias=0x55ae226034a0 <empty_clex_str>, do_not_open=true, keep_row_order=false) at /test/10.9_dbg/sql/sql_select.cc:19674
      #6  0x000055ae213c3a0b in JOIN::create_postjoin_aggr_table (this=this@entry=0x148ebc032960, tab=tab@entry=0x148ebc09d610, table_fields=table_fields@entry=0x148ebc032cc8, table_group=0x148ebc02e3e0, save_sum_fields=<optimized out>, distinct=distinct@entry=false, keep_row_order=false) at /test/10.9_dbg/sql/sql_select.cc:4055
      #7  0x000055ae213c4b12 in JOIN::make_aggr_tables_info (this=this@entry=0x148ebc032960) at /test/10.9_dbg/sql/sql_select.cc:3634
      #8  0x000055ae213d6cd2 in JOIN::optimize_stage2 (this=this@entry=0x148ebc032960) at /test/10.9_dbg/sql/sql_select.cc:3262
      #9  0x000055ae213d85a7 in JOIN::optimize_inner (this=this@entry=0x148ebc032960) at /test/10.9_dbg/sql/sql_select.cc:2521
      #10 0x000055ae213d896c in JOIN::optimize (this=this@entry=0x148ebc032960) at /test/10.9_dbg/sql/sql_select.cc:1837
      #11 0x000055ae213d8a5f in mysql_select (thd=thd@entry=0x148ebc000db8, tables=0x148ebc02a6d8, fields=@0x148ebc0143c0: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x148ebc014838, last = 0x148ebc014838, elements = 1}, <No data fields>}, conds=0x0, og_num=1, order=0x0, group=0x148ebc02e3e0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x148ebc032938, unit=0x148ebc004fd8, select_lex=0x148ebc014120) at /test/10.9_dbg/sql/sql_select.cc:5022
      #12 0x000055ae213d92a8 in handle_select (thd=thd@entry=0x148ebc000db8, lex=lex@entry=0x148ebc004f00, result=result@entry=0x148ebc032938, setup_tables_done_option=setup_tables_done_option@entry=0) at /test/10.9_dbg/sql/sql_select.cc:570
      #13 0x000055ae213456c8 in execute_sqlcom_select (thd=thd@entry=0x148ebc000db8, all_tables=0x148ebc02a6d8) at /test/10.9_dbg/sql/sql_parse.cc:6271
      #14 0x000055ae21351935 in mysql_execute_command (thd=thd@entry=0x148ebc000db8, is_called_from_prepared_stmt=is_called_from_prepared_stmt@entry=false) at /test/10.9_dbg/sql/sql_parse.cc:3961
      #15 0x000055ae2133f67b in mysql_parse (thd=thd@entry=0x148ebc000db8, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x148f4812c470) at /test/10.9_dbg/sql/sql_parse.cc:8046
      #16 0x000055ae2134cf79 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x148ebc000db8, packet=packet@entry=0x148ebc00b699 "SELECT v817 / 1.0 AS v818 FROM (SELECT DISTINCT 42 FROM (SELECT DISTINCT v817 FROM t)AS v819,t AS v820,t AS v821,t AS v822 JOIN t) AS v823 NATURAL JOIN t AS v824 NATURAL JOIN t WINDOW v832 AS (PARTITI"..., packet_length=packet_length@entry=617, blocking=blocking@entry=true) at /test/10.9_dbg/sql/sql_class.h:1364
      #17 0x000055ae2134f686 in do_command (thd=0x148ebc000db8, blocking=blocking@entry=true) at /test/10.9_dbg/sql/sql_parse.cc:1408
      #18 0x000055ae214acd02 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x55ae23d3b7c8, put_in_cache=put_in_cache@entry=true) at /test/10.9_dbg/sql/sql_connect.cc:1418
      #19 0x000055ae214ad20b in handle_one_connection (arg=0x55ae23d3b7c8) at /test/10.9_dbg/sql/sql_connect.cc:1312
      #20 0x0000148f6e7f5609 in start_thread (arg=<optimized out>) at pthread_create.c:477
      #21 0x0000148f6e3e1163 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
      

      Bug confirmed present in:
      MariaDB: 10.2.44 (dbg), 10.3.35 (dbg), 10.4.25 (dbg), 10.5.16 (dbg), 10.6.8 (dbg), 10.7.4 (dbg), 10.8.3 (dbg), 10.9.0 (dbg)

      Bug (or feature/syntax) confirmed not present in:
      MariaDB: 10.2.44 (opt), 10.3.35 (opt), 10.4.25 (opt), 10.5.16 (opt), 10.6.8 (opt), 10.7.4 (opt), 10.8.3 (opt), 10.9.0 (opt)
      MySQL: 5.5.62 (dbg), 5.5.62 (opt), 5.6.51 (dbg), 5.6.51 (opt), 5.7.37 (dbg), 5.7.37 (opt), 8.0.28 (dbg), 8.0.28 (opt)

      Attachments

        Issue Links

          Activity

            People

              Johnston Rex Johnston
              Roel Roel Van de Paar
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

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