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

SIGSEGV's in st_select_lex::mark_as_dependent and Assertion `outer_context || !*from_field || *from_field == not_found_field' failed in Item_field::fix_outer_field on INSERT

Details

    Description

      Slightly sporadic. A whole set of different stacks across different versions dbg/opt are generated. Should be executed from CLI.

      SET sql_mode='';
      CREATE TABLE v0 (v0 FLOAT) ENGINE=InnoDB;
      INSERT INTO v0 SELECT * FROM (SELECT * FROM v0 ORDER BY v0,v0) AS v0 WHERE (v0 IN (SELECT v0 AND 0 * 0 GROUP BY v0,v0,v0));
      

      Leads to:

      10.10.0 63961a08a6203f4d58363a9321e4cf9c8b07a9fe (Optimized)

      Core was generated by `/test/MD290622-mariadb-10.10.0-linux-x86_64-opt/bin/mysqld --no-defaults --core'.
      Program terminated with signal SIGSEGV, Segmentation fault.
      #0  0x000055fedf3e3cc3 in st_select_lex::mark_as_dependent (
          this=this@entry=0x14f7a4010f90, thd=thd@entry=0x14f7a4000c58, 
          last=last@entry=0x14f7a4010f90, dependency=0x14f7a404f538)
          at /test/10.10_opt/sql/sql_lex.h:1363
      1363	  st_select_lex_unit* master_unit() { return (st_select_lex_unit*) master; }
      [Current thread is 1 (Thread 0x14f81ce01700 (LWP 1089937))]
      (gdb) bt
      #0  0x000055fedf3e3cc3 in st_select_lex::mark_as_dependent (this=this@entry=0x14f7a4010f90, thd=thd@entry=0x14f7a4000c58, last=last@entry=0x14f7a4010f90, dependency=0x14f7a404f538) at /test/10.10_opt/sql/sql_lex.h:1363
      #1  0x000055fedf666b10 in mark_as_dependent (thd=0x14f7a4000c58, last=0x14f7a4010f90, current=0x14f7a4010f90, resolved_item=0x14f7a404f538, mark_item=<optimized out>, suppress_warning_output=<optimized out>) at /test/10.10_opt/sql/item.cc:5235
      #2  0x000055fedf679d86 in Item_field::fix_outer_field (this=0x14f7a404f538, thd=0x14f7a4000c58, from_field=0x14f81cdff460, reference=0x14f7a404f388) at /test/10.10_opt/sql/item.cc:5923
      #3  0x000055fedf67a9db in Item_field::fix_fields (this=0x14f7a404f538, thd=0x14f7a4000c58, reference=0x14f7a404f388) at /test/10.10_opt/sql/item.cc:6140
      #4  0x000055fedf6bdaad in Item::fix_fields_if_needed (ref=0x14f7a404f388, thd=0x14f7a4000c58, this=0x14f7a404f538) at /test/10.10_opt/sql/item.h:1142
      #5  Item::fix_fields_if_needed (ref=0x14f7a404f388, thd=0x14f7a4000c58, this=0x14f7a404f538) at /test/10.10_opt/sql/item.h:1142
      #6  Item_func::fix_fields (ref=<optimized out>, thd=0x14f7a4000c58, this=0x14f7a404f310) at /test/10.10_opt/sql/item_func.cc:347
      #7  Item_func::fix_fields (this=0x14f7a404f310, thd=0x14f7a4000c58, ref=<optimized out>) at /test/10.10_opt/sql/item_func.cc:314
      #8  0x000055fedf4828df in JOIN::optimize_inner (this=0x14f7a401e5a8) at /test/10.10_opt/sql/sql_select.cc:2201
      #9  0x000055fedf485d23 in JOIN::optimize (this=this@entry=0x14f7a401e5a8) at /test/10.10_opt/sql/sql_select.cc:1846
      #10 0x000055fedf3caebb in mysql_derived_optimize (thd=0x14f7a4000c58, lex=0x14f7a4004be0, derived=0x14f7a4012d90) at /test/10.10_opt/sql/sql_derived.cc:1064
      #11 0x000055fedf3ca708 in mysql_handle_single_derived (lex=0x14f7a4004be0, derived=derived@entry=0x14f7a4012d90, phases=phases@entry=4) at /test/10.10_opt/sql/sql_derived.cc:200
      #12 0x000055fedf482d7c in JOIN::optimize_inner (this=0x14f7a401ef20) at /test/10.10_opt/sql/sql_select.cc:2322
      #13 0x000055fedf485d23 in JOIN::optimize (this=this@entry=0x14f7a401ef20) at /test/10.10_opt/sql/sql_select.cc:1846
      #14 0x000055fedf485e0e in mysql_select (thd=0x14f7a4000c58, tables=0x14f7a4012d90, fields=@0x14f7a4011230: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x14f7a4011520, last = 0x14f7a4011520, elements = 1}, <No data fields>}, conds=0x14f7a40142b8, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=<optimized out>, result=0x14f7a401ee60, unit=0x14f7a4004cb8, select_lex=0x14f7a4010f90) at /test/10.10_opt/sql/sql_select.cc:5031
      #15 0x000055fedf4865a7 in handle_select (thd=thd@entry=0x14f7a4000c58, lex=lex@entry=0x14f7a4004be0, result=result@entry=0x14f7a401ee60, setup_tables_done_option=setup_tables_done_option@entry=1073741824) at /test/10.10_opt/sql/sql_select.cc:579
      #16 0x000055fedf4180ac in mysql_execute_command (thd=0x14f7a4000c58, is_called_from_prepared_stmt=<optimized out>) at /test/10.10_opt/sql/sql_parse.cc:4708
      #17 0x000055fedf404795 in mysql_parse (rawbuf=<optimized out>, length=<optimized out>, parser_state=<optimized out>, thd=0x14f7a4000c58) at /test/10.10_opt/sql/sql_parse.cc:8036
      #18 mysql_parse (thd=0x14f7a4000c58, rawbuf=<optimized out>, length=<optimized out>, parser_state=<optimized out>) at /test/10.10_opt/sql/sql_parse.cc:7958
      #19 0x000055fedf4102aa in dispatch_command (command=COM_QUERY, thd=0x14f7a4000c58, packet=<optimized out>, packet_length=<optimized out>, blocking=<optimized out>) at /test/10.10_opt/sql/sql_class.h:1364
      #20 0x000055fedf4121d2 in do_command (thd=0x14f7a4000c58, blocking=blocking@entry=true) at /test/10.10_opt/sql/sql_parse.cc:1407
      #21 0x000055fedf528ddf in do_handle_one_connection (connect=<optimized out>, connect@entry=0x55fee297c068, put_in_cache=put_in_cache@entry=true) at /test/10.10_opt/sql/sql_connect.cc:1418
      #22 0x000055fedf5290bd in handle_one_connection (arg=0x55fee297c068) at /test/10.10_opt/sql/sql_connect.cc:1312
      #23 0x000014f847ec0609 in start_thread (arg=<optimized out>) at pthread_create.c:477
      #24 0x000014f847aac133 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
      

      10.10.0 63961a08a6203f4d58363a9321e4cf9c8b07a9fe (Debug)

      mysqld: /test/10.10_dbg/sql/item.cc:5675: int Item_field::fix_outer_field(THD*, Field**, Item**): Assertion `outer_context || !*from_field || *from_field == not_found_field' failed.
      

      10.10.0 63961a08a6203f4d58363a9321e4cf9c8b07a9fe (Debug)

      Core was generated by `/test/MD290622-mariadb-10.10.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 0x14addc0c4700 (LWP 1090587))]
      (gdb) bt
      #0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
      #1  0x000014adf483a859 in __GI_abort () at abort.c:79
      #2  0x000014adf483a729 in __assert_fail_base (fmt=0x14adf49d0588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x562e08cf5160 "outer_context || !*from_field || *from_field == not_found_field", file=0x562e08cf2980 "/test/10.10_dbg/sql/item.cc", line=5675, function=<optimized out>) at assert.c:92
      #3  0x000014adf484bfd6 in __GI___assert_fail (assertion=assertion@entry=0x562e08cf5160 "outer_context || !*from_field || *from_field == not_found_field", file=file@entry=0x562e08cf2980 "/test/10.10_dbg/sql/item.cc", line=line@entry=5675, function=function@entry=0x562e08cf51a0 "int Item_field::fix_outer_field(THD*, Field**, Item**)") at assert.c:101
      #4  0x0000562e0829814d in Item_field::fix_outer_field (this=this@entry=0x14ad3c076e08, thd=thd@entry=0x14ad3c000db8, from_field=from_field@entry=0x14addc0c2990, reference=reference@entry=0x14ad3c076c58) at /test/10.10_dbg/sql/item.cc:5675
      #5  0x0000562e0829987b in Item_field::fix_fields (this=0x14ad3c076e08, thd=0x14ad3c000db8, reference=0x14ad3c076c58) at /test/10.10_dbg/sql/item.cc:6140
      #6  0x0000562e082edb6e in Item::fix_fields_if_needed (ref=0x14ad3c076c58, thd=0x14ad3c000db8, this=<optimized out>) at /test/10.10_dbg/sql/item.h:1144
      #7  Item_func::fix_fields (this=0x14ad3c076be0, thd=0x14ad3c000db8, ref=<optimized out>) at /test/10.10_dbg/sql/item_func.cc:347
      #8  0x0000562e08008e75 in JOIN::optimize_inner (this=this@entry=0x14ad3c027688) at /test/10.10_dbg/sql/sql_select.cc:2201
      #9  0x0000562e08009e1a in JOIN::optimize (this=this@entry=0x14ad3c027688) at /test/10.10_dbg/sql/sql_select.cc:1846
      #10 0x0000562e07f2bf50 in mysql_derived_optimize (thd=0x14ad3c000db8, lex=0x14ad3c004f00, derived=0x14ad3c0162b0) at /test/10.10_dbg/sql/sql_derived.cc:1064
      #11 0x0000562e07f2b6f7 in mysql_handle_single_derived (lex=0x14ad3c004f00, derived=derived@entry=0x14ad3c0162b0, phases=phases@entry=4) at /test/10.10_dbg/sql/sql_derived.cc:200
      #12 0x0000562e08009bab in JOIN::optimize_inner (this=this@entry=0x14ad3c028000) at /test/10.10_dbg/sql/sql_select.cc:2322
      #13 0x0000562e08009e1a in JOIN::optimize (this=this@entry=0x14ad3c028000) at /test/10.10_dbg/sql/sql_select.cc:1846
      #14 0x0000562e08009f0d in mysql_select (thd=thd@entry=0x14ad3c000db8, tables=0x14ad3c0162b0, fields=@0x14ad3c014750: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x14ad3c014a40, last = 0x14ad3c014a40, elements = 1}, <No data fields>}, conds=0x14ad3c0177d8, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2202244745984, result=0x14ad3c027f40, unit=0x14ad3c004fd8, select_lex=0x14ad3c0144b0) at /test/10.10_dbg/sql/sql_select.cc:5031
      #15 0x0000562e0800a756 in handle_select (thd=thd@entry=0x14ad3c000db8, lex=lex@entry=0x14ad3c004f00, result=result@entry=0x14ad3c027f40, setup_tables_done_option=setup_tables_done_option@entry=1073741824) at /test/10.10_dbg/sql/sql_select.cc:579
      #16 0x0000562e07f844c7 in mysql_execute_command (thd=thd@entry=0x14ad3c000db8, is_called_from_prepared_stmt=is_called_from_prepared_stmt@entry=false) at /test/10.10_dbg/sql/sql_parse.cc:4708
      #17 0x0000562e07f70372 in mysql_parse (thd=thd@entry=0x14ad3c000db8, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x14addc0c3470) at /test/10.10_dbg/sql/sql_parse.cc:8036
      #18 0x0000562e07f7d95a in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x14ad3c000db8, packet=packet@entry=0x14ad3c00b6c9 "INSERT INTO v0 SELECT * FROM (SELECT * FROM v0 ORDER BY v0,v0) AS v0 WHERE (v0 IN (SELECT v0 AND 0 * 0 GROUP BY v0,v0,v0))", packet_length=packet_length@entry=122, blocking=blocking@entry=true) at /test/10.10_dbg/sql/sql_class.h:1364
      #19 0x0000562e07f80064 in do_command (thd=0x14ad3c000db8, blocking=blocking@entry=true) at /test/10.10_dbg/sql/sql_parse.cc:1407
      #20 0x0000562e080dffde in do_handle_one_connection (connect=<optimized out>, connect@entry=0x562e0b51f6b8, put_in_cache=put_in_cache@entry=true) at /test/10.10_dbg/sql/sql_connect.cc:1418
      #21 0x0000562e080e04e7 in handle_one_connection (arg=0x562e0b51f6b8) at /test/10.10_dbg/sql/sql_connect.cc:1312
      #22 0x000014adf4d4b609 in start_thread (arg=<optimized out>) at pthread_create.c:477
      #23 0x000014adf4937133 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

            A testcase with some slightly different stacks

            CREATE TABLE t0(c INT KEY) ENGINE=InnoDB;
            INSERT INTO t0 SELECT * FROM(SELECT * FROM t0)AS c NATURAL JOIN t0 WHERE + 0 NOT IN ((SELECT CASE WHEN 0 THEN 0 WHEN 0 THEN 0 WHEN (0) THEN (c,c,c)=(0,0,-0) END));
            

            Leads to:

            10.10.0 88b22356e623fd63aa87273a895521a6e6667bc7 (Debug)

            mysqld: /test/10.10_dbg/sql/item.cc:5675: int Item_field::fix_outer_field(THD*, Field**, Item**): Assertion `outer_context || !*from_field || *from_field == not_found_field' failed.
            

            10.10.0 88b22356e623fd63aa87273a895521a6e6667bc7 (Debug)

            Core was generated by `/test/MD120722-mariadb-10.10.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 0x1530640a9700 (LWP 1187890))]
            (gdb) bt
            #0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
            #1  0x000015307c629859 in __GI_abort () at abort.c:79
            #2  0x000015307c629729 in __assert_fail_base (fmt=0x15307c7bf588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x56040abb6160 "outer_context || !*from_field || *from_field == not_found_field", file=0x56040abb3980 "/test/10.10_dbg/sql/item.cc", line=5675, function=<optimized out>) at assert.c:92
            #3  0x000015307c63afd6 in __GI___assert_fail (assertion=assertion@entry=0x56040abb6160 "outer_context || !*from_field || *from_field == not_found_field", file=file@entry=0x56040abb3980 "/test/10.10_dbg/sql/item.cc", line=line@entry=5675, function=function@entry=0x56040abb61a0 "int Item_field::fix_outer_field(THD*, Field**, Item**)") at assert.c:101
            #4  0x000056040a15023f in Item_field::fix_outer_field (this=this@entry=0x1530240789a8, thd=thd@entry=0x153024000db8, from_field=from_field@entry=0x1530640a73b0, reference=reference@entry=0x153024077a28) at /test/10.10_dbg/sql/item.cc:5675
            #5  0x000056040a15196d in Item_field::fix_fields (this=0x1530240789a8, thd=0x153024000db8, reference=0x153024077a28) at /test/10.10_dbg/sql/item.cc:6140
            #6  0x000056040a1eefd2 in Item::fix_fields_if_needed (ref=0x153024077a28, thd=0x153024000db8, this=<optimized out>) at /test/10.10_dbg/sql/item.h:1144
            #7  Item_row::fix_fields (this=0x1530240780e8, thd=0x153024000db8, ref=<optimized out>) at /test/10.10_dbg/sql/item_row.cc:46
            #8  0x000056040a1a5c60 in Item::fix_fields_if_needed (ref=0x153024078430, thd=0x153024000db8, this=<optimized out>) at /test/10.10_dbg/sql/item.h:1144
            #9  Item_func::fix_fields (this=0x1530240783b8, thd=0x153024000db8, ref=<optimized out>) at /test/10.10_dbg/sql/item_func.cc:347
            #10 0x000056040a1a5c60 in Item::fix_fields_if_needed (ref=0x1530240777c8, thd=0x153024000db8, this=<optimized out>) at /test/10.10_dbg/sql/item.h:1144
            #11 Item_func::fix_fields (this=this@entry=0x1530240785e0, thd=0x153024000db8, ref=<optimized out>) at /test/10.10_dbg/sql/item_func.cc:347
            #12 0x000056040a167359 in Item_func_case::fix_fields (this=0x1530240785e0, thd=<optimized out>, ref=<optimized out>) at /test/10.10_dbg/sql/item_cmpfunc.cc:3130
            #13 0x000056040a1a5c60 in Item::fix_fields_if_needed (ref=0x153024078740, thd=0x153024000db8, this=<optimized out>) at /test/10.10_dbg/sql/item.h:1144
            #14 Item_func::fix_fields (this=0x1530240786c0, thd=0x153024000db8, ref=<optimized out>) at /test/10.10_dbg/sql/item_func.cc:347
            #15 0x000056040a1a5c60 in Item::fix_fields_if_needed (ref=0x153024078960, thd=0x153024000db8, this=<optimized out>) at /test/10.10_dbg/sql/item.h:1144
            #16 Item_func::fix_fields (this=this@entry=0x1530240788e8, thd=thd@entry=0x153024000db8, ref=ref@entry=0x1530240269b0) at /test/10.10_dbg/sql/item_func.cc:347
            #17 0x000056040a16dffa in Item_func_not::fix_fields (this=0x1530240788e8, thd=0x153024000db8, ref=0x1530240269b0) at /test/10.10_dbg/sql/item_cmpfunc.cc:6451
            #18 0x0000560409ec0f67 in JOIN::optimize_inner (this=this@entry=0x153024026560) at /test/10.10_dbg/sql/sql_select.cc:2201
            #19 0x0000560409ec1f0c in JOIN::optimize (this=this@entry=0x153024026560) at /test/10.10_dbg/sql/sql_select.cc:1846
            #20 0x0000560409de4042 in mysql_derived_optimize (thd=0x153024000db8, lex=0x153024004f00, derived=0x153024015fc8) at /test/10.10_dbg/sql/sql_derived.cc:1064
            #21 0x0000560409de37e9 in mysql_handle_single_derived (lex=0x153024004f00, derived=derived@entry=0x153024015fc8, phases=phases@entry=4) at /test/10.10_dbg/sql/sql_derived.cc:200
            #22 0x0000560409ec1c9d in JOIN::optimize_inner (this=this@entry=0x1530240274a0) at /test/10.10_dbg/sql/sql_select.cc:2322
            #23 0x0000560409ec1f0c in JOIN::optimize (this=this@entry=0x1530240274a0) at /test/10.10_dbg/sql/sql_select.cc:1846
            #24 0x0000560409ec1fff in mysql_select (thd=thd@entry=0x153024000db8, tables=0x153024015fc8, fields=@0x1530240147a0: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x153024014a90, last = 0x153024014a90, elements = 1}, <No data fields>}, conds=0x153024025ad8, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2202244745984, result=0x1530240273e0, unit=0x153024004fd8, select_lex=0x153024014500) at /test/10.10_dbg/sql/sql_select.cc:5031
            #25 0x0000560409ec2848 in handle_select (thd=thd@entry=0x153024000db8, lex=lex@entry=0x153024004f00, result=result@entry=0x1530240273e0, setup_tables_done_option=setup_tables_done_option@entry=1073741824) at /test/10.10_dbg/sql/sql_select.cc:579
            #26 0x0000560409e3c5b9 in mysql_execute_command (thd=thd@entry=0x153024000db8, is_called_from_prepared_stmt=is_called_from_prepared_stmt@entry=false) at /test/10.10_dbg/sql/sql_parse.cc:4708
            #27 0x0000560409e28464 in mysql_parse (thd=thd@entry=0x153024000db8, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x1530640a8470) at /test/10.10_dbg/sql/sql_parse.cc:8036
            #28 0x0000560409e35a4c in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x153024000db8, packet=packet@entry=0x15302400b6c9 "INSERT INTO t0 SELECT * FROM(SELECT * FROM t0)AS c NATURAL JOIN t0 WHERE + 0 NOT IN ((SELECT CASE WHEN 0 THEN 0 WHEN 0 THEN 0 WHEN (0) THEN (c,c,c)=(0,0,-0) END))", packet_length=packet_length@entry=162, blocking=blocking@entry=true) at /test/10.10_dbg/sql/sql_class.h:1364
            #29 0x0000560409e38156 in do_command (thd=0x153024000db8, blocking=blocking@entry=true) at /test/10.10_dbg/sql/sql_parse.cc:1407
            #30 0x0000560409f980d0 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x56040d5a6618, put_in_cache=put_in_cache@entry=true) at /test/10.10_dbg/sql/sql_connect.cc:1418
            #31 0x0000560409f985d9 in handle_one_connection (arg=0x56040d5a6618) at /test/10.10_dbg/sql/sql_connect.cc:1312
            #32 0x000015307cb3a609 in start_thread (arg=<optimized out>) at pthread_create.c:477
            #33 0x000015307c726133 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
            

            Bug confirmed present in:
            MariaDB: 10.3.36 (dbg), 10.3.36 (opt), 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:
            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)

            Roel Roel Van de Paar added a comment - A testcase with some slightly different stacks CREATE TABLE t0(c INT KEY ) ENGINE=InnoDB; INSERT INTO t0 SELECT * FROM ( SELECT * FROM t0) AS c NATURAL JOIN t0 WHERE + 0 NOT IN (( SELECT CASE WHEN 0 THEN 0 WHEN 0 THEN 0 WHEN (0) THEN (c,c,c)=(0,0,-0) END )); Leads to: 10.10.0 88b22356e623fd63aa87273a895521a6e6667bc7 (Debug) mysqld: /test/10.10_dbg/sql/item.cc:5675: int Item_field::fix_outer_field(THD*, Field**, Item**): Assertion `outer_context || !*from_field || *from_field == not_found_field' failed. 10.10.0 88b22356e623fd63aa87273a895521a6e6667bc7 (Debug) Core was generated by `/test/MD120722-mariadb-10.10.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 0x1530640a9700 (LWP 1187890))] (gdb) bt #0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50 #1 0x000015307c629859 in __GI_abort () at abort.c:79 #2 0x000015307c629729 in __assert_fail_base (fmt=0x15307c7bf588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x56040abb6160 "outer_context || !*from_field || *from_field == not_found_field", file=0x56040abb3980 "/test/10.10_dbg/sql/item.cc", line=5675, function=<optimized out>) at assert.c:92 #3 0x000015307c63afd6 in __GI___assert_fail (assertion=assertion@entry=0x56040abb6160 "outer_context || !*from_field || *from_field == not_found_field", file=file@entry=0x56040abb3980 "/test/10.10_dbg/sql/item.cc", line=line@entry=5675, function=function@entry=0x56040abb61a0 "int Item_field::fix_outer_field(THD*, Field**, Item**)") at assert.c:101 #4 0x000056040a15023f in Item_field::fix_outer_field (this=this@entry=0x1530240789a8, thd=thd@entry=0x153024000db8, from_field=from_field@entry=0x1530640a73b0, reference=reference@entry=0x153024077a28) at /test/10.10_dbg/sql/item.cc:5675 #5 0x000056040a15196d in Item_field::fix_fields (this=0x1530240789a8, thd=0x153024000db8, reference=0x153024077a28) at /test/10.10_dbg/sql/item.cc:6140 #6 0x000056040a1eefd2 in Item::fix_fields_if_needed (ref=0x153024077a28, thd=0x153024000db8, this=<optimized out>) at /test/10.10_dbg/sql/item.h:1144 #7 Item_row::fix_fields (this=0x1530240780e8, thd=0x153024000db8, ref=<optimized out>) at /test/10.10_dbg/sql/item_row.cc:46 #8 0x000056040a1a5c60 in Item::fix_fields_if_needed (ref=0x153024078430, thd=0x153024000db8, this=<optimized out>) at /test/10.10_dbg/sql/item.h:1144 #9 Item_func::fix_fields (this=0x1530240783b8, thd=0x153024000db8, ref=<optimized out>) at /test/10.10_dbg/sql/item_func.cc:347 #10 0x000056040a1a5c60 in Item::fix_fields_if_needed (ref=0x1530240777c8, thd=0x153024000db8, this=<optimized out>) at /test/10.10_dbg/sql/item.h:1144 #11 Item_func::fix_fields (this=this@entry=0x1530240785e0, thd=0x153024000db8, ref=<optimized out>) at /test/10.10_dbg/sql/item_func.cc:347 #12 0x000056040a167359 in Item_func_case::fix_fields (this=0x1530240785e0, thd=<optimized out>, ref=<optimized out>) at /test/10.10_dbg/sql/item_cmpfunc.cc:3130 #13 0x000056040a1a5c60 in Item::fix_fields_if_needed (ref=0x153024078740, thd=0x153024000db8, this=<optimized out>) at /test/10.10_dbg/sql/item.h:1144 #14 Item_func::fix_fields (this=0x1530240786c0, thd=0x153024000db8, ref=<optimized out>) at /test/10.10_dbg/sql/item_func.cc:347 #15 0x000056040a1a5c60 in Item::fix_fields_if_needed (ref=0x153024078960, thd=0x153024000db8, this=<optimized out>) at /test/10.10_dbg/sql/item.h:1144 #16 Item_func::fix_fields (this=this@entry=0x1530240788e8, thd=thd@entry=0x153024000db8, ref=ref@entry=0x1530240269b0) at /test/10.10_dbg/sql/item_func.cc:347 #17 0x000056040a16dffa in Item_func_not::fix_fields (this=0x1530240788e8, thd=0x153024000db8, ref=0x1530240269b0) at /test/10.10_dbg/sql/item_cmpfunc.cc:6451 #18 0x0000560409ec0f67 in JOIN::optimize_inner (this=this@entry=0x153024026560) at /test/10.10_dbg/sql/sql_select.cc:2201 #19 0x0000560409ec1f0c in JOIN::optimize (this=this@entry=0x153024026560) at /test/10.10_dbg/sql/sql_select.cc:1846 #20 0x0000560409de4042 in mysql_derived_optimize (thd=0x153024000db8, lex=0x153024004f00, derived=0x153024015fc8) at /test/10.10_dbg/sql/sql_derived.cc:1064 #21 0x0000560409de37e9 in mysql_handle_single_derived (lex=0x153024004f00, derived=derived@entry=0x153024015fc8, phases=phases@entry=4) at /test/10.10_dbg/sql/sql_derived.cc:200 #22 0x0000560409ec1c9d in JOIN::optimize_inner (this=this@entry=0x1530240274a0) at /test/10.10_dbg/sql/sql_select.cc:2322 #23 0x0000560409ec1f0c in JOIN::optimize (this=this@entry=0x1530240274a0) at /test/10.10_dbg/sql/sql_select.cc:1846 #24 0x0000560409ec1fff in mysql_select (thd=thd@entry=0x153024000db8, tables=0x153024015fc8, fields=@0x1530240147a0: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x153024014a90, last = 0x153024014a90, elements = 1}, <No data fields>}, conds=0x153024025ad8, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2202244745984, result=0x1530240273e0, unit=0x153024004fd8, select_lex=0x153024014500) at /test/10.10_dbg/sql/sql_select.cc:5031 #25 0x0000560409ec2848 in handle_select (thd=thd@entry=0x153024000db8, lex=lex@entry=0x153024004f00, result=result@entry=0x1530240273e0, setup_tables_done_option=setup_tables_done_option@entry=1073741824) at /test/10.10_dbg/sql/sql_select.cc:579 #26 0x0000560409e3c5b9 in mysql_execute_command (thd=thd@entry=0x153024000db8, is_called_from_prepared_stmt=is_called_from_prepared_stmt@entry=false) at /test/10.10_dbg/sql/sql_parse.cc:4708 #27 0x0000560409e28464 in mysql_parse (thd=thd@entry=0x153024000db8, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x1530640a8470) at /test/10.10_dbg/sql/sql_parse.cc:8036 #28 0x0000560409e35a4c in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x153024000db8, packet=packet@entry=0x15302400b6c9 "INSERT INTO t0 SELECT * FROM(SELECT * FROM t0)AS c NATURAL JOIN t0 WHERE + 0 NOT IN ((SELECT CASE WHEN 0 THEN 0 WHEN 0 THEN 0 WHEN (0) THEN (c,c,c)=(0,0,-0) END))", packet_length=packet_length@entry=162, blocking=blocking@entry=true) at /test/10.10_dbg/sql/sql_class.h:1364 #29 0x0000560409e38156 in do_command (thd=0x153024000db8, blocking=blocking@entry=true) at /test/10.10_dbg/sql/sql_parse.cc:1407 #30 0x0000560409f980d0 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x56040d5a6618, put_in_cache=put_in_cache@entry=true) at /test/10.10_dbg/sql/sql_connect.cc:1418 #31 0x0000560409f985d9 in handle_one_connection (arg=0x56040d5a6618) at /test/10.10_dbg/sql/sql_connect.cc:1312 #32 0x000015307cb3a609 in start_thread (arg=<optimized out>) at pthread_create.c:477 #33 0x000015307c726133 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95 Bug confirmed present in: MariaDB: 10.3.36 (dbg), 10.3.36 (opt), 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: 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)
            alice Alice Sherepa added a comment -

            test case from MDEV-32604, repeatable on 10.4-11.2:

            CREATE TABLE t1 ( a int ) ;
            INSERT INTO t1 SELECT 36 FROM (SELECT a  FROM t1 ) t WHERE a IN ( SELECT a = 'x' ) ;
            

            Version: '10.4.32-MariaDB-debug-log'  
            mysqld: /10.4/src/sql/item.cc:5567: int Item_field::fix_outer_field(THD*, Field**, Item**): Assertion `outer_context || !*from_field || *from_field == not_found_field' failed.
            231030 18:05:16 [ERROR] mysqld got signal 6 ;
             
            Server version: 10.4.32-MariaDB-debug-log source revision: 11abc2191149a76702ef5d919e2e8940e47e5ef9
             
            sql/signal_handler.cc:235(handle_fatal_signal)[0x5651175bf955]
            sql/item.cc:5570(Item_field::fix_outer_field(THD*, Field**, Item**))[0x56511763f71f]
            sql/item.cc:6017(Item_field::fix_fields(THD*, Item**))[0x56511764376d]
            sql/item.h:966(Item::fix_fields_if_needed(THD*, Item**))[0x565116b5e5e5]
            sql/item_func.cc:355(Item_func::fix_fields(THD*, Item**))[0x56511771d35a]
            sql/sql_select.cc:2083(JOIN::optimize_inner())[0x565116ebb21d]
            sql/sql_select.cc:1711(JOIN::optimize())[0x565116eb7359]
            sql/sql_derived.cc:1029(mysql_derived_optimize(THD*, LEX*, TABLE_LIST*))[0x565116d2b3f9]
            sql/sql_derived.cc:200(mysql_handle_single_derived(LEX*, TABLE_LIST*, unsigned int))[0x565116d25ba4]
            sql/sql_select.cc:2201(JOIN::optimize_inner())[0x565116ebc8be]
            sql/sql_select.cc:1711(JOIN::optimize())[0x565116eb7359]
            sql/sql_select.cc:4812(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*))[0x565116ed8343]
            sql/sql_select.cc:442(handle_select(THD*, LEX*, select_result*, unsigned long))[0x565116ea902c]
            sql/sql_parse.cc:4729(mysql_execute_command(THD*))[0x565116e07380]
            sql/sql_parse.cc:8013(mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool))[0x565116e1e30b]
            sql/sql_parse.cc:1860(dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool))[0x565116df46cd]
            sql/sql_parse.cc:1378(do_command(THD*))[0x565116df11f8]
            sql/sql_connect.cc:1420(do_handle_one_connection(CONNECT*))[0x56511720076f]
            sql/sql_connect.cc:1325(handle_one_connection)[0x565117200013]
            perfschema/pfs.cc:1871(pfs_spawn_thread)[0x565117eabe86]
            nptl/pthread_create.c:478(start_thread)[0x7fa9f4f39609]
             
            Query (0x62b0000a1290): INSERT INTO t1 SELECT 36 FROM (SELECT a  FROM t1 ) t WHERE a IN ( SELECT a = 'x' )
            
            

            alice Alice Sherepa added a comment - test case from MDEV-32604 , repeatable on 10.4-11.2: CREATE TABLE t1 ( a int ) ; INSERT INTO t1 SELECT 36 FROM ( SELECT a FROM t1 ) t WHERE a IN ( SELECT a = 'x' ) ; Version: '10.4.32-MariaDB-debug-log' mysqld: /10.4/src/sql/item.cc:5567: int Item_field::fix_outer_field(THD*, Field**, Item**): Assertion `outer_context || !*from_field || *from_field == not_found_field' failed. 231030 18:05:16 [ERROR] mysqld got signal 6 ;   Server version: 10.4.32-MariaDB-debug-log source revision: 11abc2191149a76702ef5d919e2e8940e47e5ef9   sql/signal_handler.cc:235(handle_fatal_signal)[0x5651175bf955] sql/item.cc:5570(Item_field::fix_outer_field(THD*, Field**, Item**))[0x56511763f71f] sql/item.cc:6017(Item_field::fix_fields(THD*, Item**))[0x56511764376d] sql/item.h:966(Item::fix_fields_if_needed(THD*, Item**))[0x565116b5e5e5] sql/item_func.cc:355(Item_func::fix_fields(THD*, Item**))[0x56511771d35a] sql/sql_select.cc:2083(JOIN::optimize_inner())[0x565116ebb21d] sql/sql_select.cc:1711(JOIN::optimize())[0x565116eb7359] sql/sql_derived.cc:1029(mysql_derived_optimize(THD*, LEX*, TABLE_LIST*))[0x565116d2b3f9] sql/sql_derived.cc:200(mysql_handle_single_derived(LEX*, TABLE_LIST*, unsigned int))[0x565116d25ba4] sql/sql_select.cc:2201(JOIN::optimize_inner())[0x565116ebc8be] sql/sql_select.cc:1711(JOIN::optimize())[0x565116eb7359] sql/sql_select.cc:4812(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*))[0x565116ed8343] sql/sql_select.cc:442(handle_select(THD*, LEX*, select_result*, unsigned long))[0x565116ea902c] sql/sql_parse.cc:4729(mysql_execute_command(THD*))[0x565116e07380] sql/sql_parse.cc:8013(mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool))[0x565116e1e30b] sql/sql_parse.cc:1860(dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool))[0x565116df46cd] sql/sql_parse.cc:1378(do_command(THD*))[0x565116df11f8] sql/sql_connect.cc:1420(do_handle_one_connection(CONNECT*))[0x56511720076f] sql/sql_connect.cc:1325(handle_one_connection)[0x565117200013] perfschema/pfs.cc:1871(pfs_spawn_thread)[0x565117eabe86] nptl/pthread_create.c:478(start_thread)[0x7fa9f4f39609]   Query (0x62b0000a1290): INSERT INTO t1 SELECT 36 FROM (SELECT a FROM t1 ) t WHERE a IN ( SELECT a = 'x' )

            People

              shulga Dmitry Shulga
              Roel Roel Van de Paar
              Votes:
              0 Vote for this issue
              Watchers:
              3 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.