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

SIGSEGV in looped best_extension_by_limited_search from greedy_search on NATURAL JOIN | SIGSEGV in restore_prev_nj_state

Details

    Description

      The following testcase, sporadically (average occurrence about once every 90-400 attempts):

      # Loop 90-3000 times
      DROP DATABASE test;
      CREATE DATABASE test;
      USE test;
      CREATE TABLE t3 (b VARCHAR (1));
      CREATE TABLE t2 (c2 INT);
      SET SESSION join_cache_level=3;
      INSERT INTO t2 VALUES (14619+0.75);
      CREATE TEMPORARY TABLE t1 AS SELECT * FROM mysql.user;
      DELETE IGNORE a2,a3 FROM t2 AS a1 JOIN t AS a2 INNER JOIN t2 AS a3;
      SELECT * FROM (SELECT * FROM t1 NATURAL JOIN t2) AS a NATURAL LEFT JOIN (SELECT * FROM t1 NATURAL JOIN t3) AS b;
      

      Leads to:

      10.5.6 2bac9782aa81ad386beaf00eb126ccf2d15031a1 (Optimized)

      Core was generated by `/test/MD150920-mariadb-10.5.6-linux-x86_64-opt/bin/mysqld --no-defaults --core-'.
      Program terminated with signal SIGSEGV, Segmentation fault.
      #0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=11)
          at ../sysdeps/unix/sysv/linux/pthread_kill.c:57
      [Current thread is 1 (Thread 0x146715e52700 (LWP 3260361))]
      (gdb) bt
      #0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=11) at ../sysdeps/unix/sysv/linux/pthread_kill.c:57
      #1  0x000055acfc476ae7 in my_write_core (sig=sig@entry=11) at /data/10.5_opt/mysys/stacktrace.c:424
      #2  0x000055acfbe45fda in handle_fatal_signal (sig=11) at /data/10.5_opt/sql/signal_handler.cc:330
      #3  <signal handler called>
      #4  best_extension_by_limited_search (join=join@entry=0x1466f1d7cf70, remaining_tables=remaining_tables@entry=2, idx=idx@entry=3, record_count=record_count@entry=7, read_time=12, search_depth=search_depth@entry=59, prune_level=prune_level@entry=1, use_cond_selectivity=use_cond_selectivity@entry=4) at /data/10.5_opt/sql/sql_select.cc:9631
      #5  0x000055acfbc88046 in best_extension_by_limited_search (join=join@entry=0x1466f1d7cf70, remaining_tables=remaining_tables@entry=10, idx=idx@entry=2, record_count=record_count@entry=7, read_time=3.5999999999999996, search_depth=search_depth@entry=60, prune_level=prune_level@entry=1, use_cond_selectivity=use_cond_selectivity@entry=4) at /data/10.5_opt/sql/sql_select.cc:9633
      #6  0x000055acfbc88046 in best_extension_by_limited_search (join=join@entry=0x1466f1d7cf70, remaining_tables=remaining_tables@entry=11, idx=idx@entry=1, record_count=record_count@entry=1, read_time=1.2, search_depth=search_depth@entry=61, prune_level=prune_level@entry=1, use_cond_selectivity=use_cond_selectivity@entry=4) at /data/10.5_opt/sql/sql_select.cc:9633
      #7  0x000055acfbc88046 in best_extension_by_limited_search (join=join@entry=0x1466f1d7cf70, remaining_tables=remaining_tables@entry=15, idx=idx@entry=0, record_count=1, read_time=read_time@entry=0, search_depth=search_depth@entry=62, prune_level=prune_level@entry=1, use_cond_selectivity=4) at /data/10.5_opt/sql/sql_select.cc:9633
      #8  0x000055acfbc8837a in greedy_search (use_cond_selectivity=<optimized out>, prune_level=<optimized out>, search_depth=62, remaining_tables=15, join=0x1466f1d7cf70) at /data/10.5_opt/sql/sql_select.cc:8750
      #9  choose_plan (join=join@entry=0x1466f1d7cf70, join_tables=<optimized out>) at /data/10.5_opt/sql/sql_select.cc:8315
      #10 0x000055acfbca8ec2 in make_join_statistics (keyuse_array=0x1466f1d7d260, tables_list=@0x1466f1c473b0: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x1466f1d55770, last = 0x1466f1d86f08, elements = 4}, <No data fields>}, join=0x1466f1d7cf70) at /data/10.5_opt/sql/sql_select.cc:5555
      #11 JOIN::optimize_inner (this=this@entry=0x1466f1d7cf70) at /data/10.5_opt/sql/sql_select.cc:2247
      #12 0x000055acfbca9533 in JOIN::optimize (this=this@entry=0x1466f1d7cf70) at /data/10.5_opt/sql/sql_select.cc:1623
      #13 0x000055acfbca9631 in mysql_select (thd=thd@entry=0x1466f1c12018, tables=0x1466f1c49af0, fields=@0x1466f1c472c0: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x1466f1c47720, last = 0x1466f1d9a820, elements = 49}, <No data fields>}, conds=0x0, og_num=<optimized out>, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x1466f1c4ce38, unit=0x1466f1c15ff0, select_lex=0x1466f1c47170) at /data/10.5_opt/sql/sql_select.cc:4649
      #14 0x000055acfbcaa041 in handle_select (thd=thd@entry=0x1466f1c12018, lex=lex@entry=0x1466f1c15f28, result=result@entry=0x1466f1c4ce38, setup_tables_done_option=setup_tables_done_option@entry=0) at /data/10.5_opt/sql/sql_select.cc:417
      #15 0x000055acfbc4f8f1 in execute_sqlcom_select (thd=thd@entry=0x1466f1c12018, all_tables=0x1466f1c49af0) at /data/10.5_opt/sql/sql_parse.cc:6210
      #16 0x000055acfbc4bfd1 in mysql_execute_command (thd=thd@entry=0x1466f1c12018) at /data/10.5_opt/sql/sql_parse.cc:3932
      #17 0x000055acfbc52a2c in mysql_parse (thd=0x1466f1c12018, rawbuf=<optimized out>, length=111, parser_state=0x146715e51430, is_com_multi=<optimized out>, is_next_command=<optimized out>) at /data/10.5_opt/sql/sql_parse.cc:7994
      #18 0x000055acfbc47cc5 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x1466f1c12018, packet=packet@entry=0x1466f1c3a019 "SELECT * FROM (SELECT * FROM t1 NATURAL JOIN t2) AS a NATURAL LEFT JOIN (SELECT * FROM t1 NATURAL JOIN t3) AS b", packet_length=packet_length@entry=111, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /data/10.5_opt/sql/sql_parse.cc:1867
      #19 0x000055acfbc45fe4 in do_command (thd=0x1466f1c12018) at /data/10.5_opt/sql/sql_parse.cc:1348
      #20 0x000055acfbd3cba1 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x146712c338f8, put_in_cache=put_in_cache@entry=true) at /data/10.5_opt/sql/sql_connect.cc:1410
      #21 0x000055acfbd3cf14 in handle_one_connection (arg=arg@entry=0x146712c338f8) at /data/10.5_opt/sql/sql_connect.cc:1312
      #22 0x000055acfc0b0a4a in pfs_spawn_thread (arg=0x146712c4f018) at /data/10.5_opt/storage/perfschema/pfs.cc:2201
      #23 0x0000146714dcb6db in start_thread (arg=0x146715e52700) at pthread_create.c:463
      #24 0x00001467141c9a3f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
      

      10.5.6 2bac9782aa81ad386beaf00eb126ccf2d15031a1 (Debug)

      Core was generated by `/test/MD150920-mariadb-10.5.6-linux-x86_64-dbg/bin/mysqld --no-defaults --core-'.
      Program terminated with signal SIGSEGV, Segmentation fault.
      #0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=11)
          at ../sysdeps/unix/sysv/linux/pthread_kill.c:57
      [Current thread is 1 (Thread 0x14b047ab9700 (LWP 3272302))]
      (gdb) bt
      #0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=11) at ../sysdeps/unix/sysv/linux/pthread_kill.c:57
      #1  0x0000557485c8185a in my_write_core (sig=sig@entry=11) at /test/10.5_dbg/mysys/stacktrace.c:424
      #2  0x00005574854483a9 in handle_fatal_signal (sig=11) at /test/10.5_dbg/sql/signal_handler.cc:330
      #3  <signal handler called>
      #4  0x00005574852017ff in best_extension_by_limited_search (join=join@entry=0x14b024160fe0, remaining_tables=remaining_tables@entry=2, idx=idx@entry=3, record_count=record_count@entry=7, read_time=12, search_depth=search_depth@entry=59, prune_level=prune_level@entry=1, use_cond_selectivity=use_cond_selectivity@entry=4) at /test/10.5_dbg/sql/sql_select.cc:9631
      #5  0x000055748520185c in best_extension_by_limited_search (join=join@entry=0x14b024160fe0, remaining_tables=remaining_tables@entry=10, idx=idx@entry=2, record_count=record_count@entry=7, read_time=3.5999999999999996, search_depth=search_depth@entry=60, prune_level=prune_level@entry=1, use_cond_selectivity=use_cond_selectivity@entry=4) at /test/10.5_dbg/sql/sql_select.cc:9633
      #6  0x000055748520185c in best_extension_by_limited_search (join=join@entry=0x14b024160fe0, remaining_tables=remaining_tables@entry=11, idx=idx@entry=1, record_count=record_count@entry=1, read_time=1.2, search_depth=search_depth@entry=61, prune_level=prune_level@entry=1, use_cond_selectivity=use_cond_selectivity@entry=4) at /test/10.5_dbg/sql/sql_select.cc:9633
      #7  0x000055748520185c in best_extension_by_limited_search (join=join@entry=0x14b024160fe0, remaining_tables=remaining_tables@entry=15, idx=idx@entry=0, record_count=record_count@entry=1, read_time=read_time@entry=0, search_depth=search_depth@entry=62, prune_level=prune_level@entry=1, use_cond_selectivity=use_cond_selectivity@entry=4) at /test/10.5_dbg/sql/sql_select.cc:9633
      #8  0x0000557485202cf0 in greedy_search (use_cond_selectivity=<optimized out>, prune_level=<optimized out>, search_depth=62, remaining_tables=15, join=0x14b024160fe0) at /test/10.5_dbg/sql/sql_select.cc:8750
      #9  choose_plan (join=join@entry=0x14b024160fe0, join_tables=<optimized out>) at /test/10.5_dbg/sql/sql_select.cc:8315
      #10 0x0000557485213dbd in make_join_statistics (keyuse_array=0x14b0241612d0, tables_list=<optimized out>, join=0x14b024160fe0) at /test/10.5_dbg/sql/sql_select.cc:5555
      #11 JOIN::optimize_inner (this=this@entry=0x14b024160fe0) at /test/10.5_dbg/sql/sql_select.cc:2247
      #12 0x00005574852143b3 in JOIN::optimize (this=this@entry=0x14b024160fe0) at /test/10.5_dbg/sql/sql_select.cc:1623
      #13 0x0000557485214d40 in mysql_select (thd=thd@entry=0x14b024015088, tables=<optimized out>, fields=@0x14b024074330: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x14b024074790, last = 0x14b02421e890, elements = 49}, <No data fields>}, conds=0x0, og_num=0, order=<optimized out>, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x14b024079ea8, unit=0x14b024019220, select_lex=0x14b0240741e0) at /test/10.5_dbg/sql/sql_select.cc:4649
      #14 0x00005574852150bc in handle_select (thd=thd@entry=0x14b024015088, lex=lex@entry=0x14b024019158, result=result@entry=0x14b024079ea8, setup_tables_done_option=setup_tables_done_option@entry=0) at /test/10.5_dbg/sql/sql_select.cc:417
      #15 0x000055748519c348 in execute_sqlcom_select (thd=thd@entry=0x14b024015088, all_tables=0x14b024076b60) at /test/10.5_dbg/sql/sql_parse.cc:6210
      #16 0x000055748519541c in mysql_execute_command (thd=thd@entry=0x14b024015088) at /test/10.5_dbg/sql/sql_parse.cc:3932
      #17 0x00005574851a2324 in mysql_parse (thd=thd@entry=0x14b024015088, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x14b047ab8350, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/10.5_dbg/sql/sql_parse.cc:7994
      #18 0x000055748518ed54 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x14b024015088, packet=packet@entry=0x14b024067089 "SELECT * FROM (SELECT * FROM t1 NATURAL JOIN t2) AS a NATURAL LEFT JOIN (SELECT * FROM t1 NATURAL JOIN t3) AS b", packet_length=packet_length@entry=111, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/10.5_dbg/sql/sql_parse.cc:1867
      #19 0x000055748518d53e in do_command (thd=0x14b024015088) at /test/10.5_dbg/sql/sql_parse.cc:1348
      #20 0x00005574852ec893 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x14b0268d4108, put_in_cache=put_in_cache@entry=true) at /test/10.5_dbg/sql/sql_connect.cc:1410
      #21 0x00005574852ecfb7 in handle_one_connection (arg=arg@entry=0x14b0268d4108) at /test/10.5_dbg/sql/sql_connect.cc:1312
      #22 0x00005574857575c2 in pfs_spawn_thread (arg=0x14b044846508) at /test/10.5_dbg/storage/perfschema/pfs.cc:2201
      #23 0x000014b046a326db in start_thread (arg=0x14b047ab9700) at pthread_create.c:463
      #24 0x000014b045e30a3f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
      

      Bug confirmed present in:
      MariaDB: 10.4.15 (dbg), 10.4.15 (opt), 10.5.6 (dbg), 10.5.6 (opt), 10.6.0 (dbg), 10.6.0 (opt)

      Bug confirmed not present in:
      MariaDB: 10.1.47 (dbg), 10.1.47 (opt), 10.2.34 (dbg), 10.2.34 (opt), 10.3.25 (dbg), 10.3.25 (opt)
      MySQL: 5.5.62 (dbg), 5.5.62 (opt), 5.6.49 (dbg), 5.6.49 (opt), 5.7.31 (dbg), 5.7.31 (opt), 8.0.21 (dbg), 8.0.21 (opt)

      Attachments

        Issue Links

          Activity

            Also saw a slightly different stack. It may be that replaying via the C-connector instead of at the CLI generates a slightly different stack (notice the one less best_extension_by_limited_search) even if join_cache_level=3 remains the same. If so, it is interesting; why does the CLI seem to produce one extra best_extension_by_limited_search call?

            10.5.6 7fba16d53fe3c2fa241434e1ff715e6a3789c79a

            Core was generated by `/test/MD031020-mariadb-10.5.6-linux-x86_64-opt/bin/mysqld --no-defaults --max_a'.
            Program terminated with signal SIGSEGV, Segmentation fault.
            #0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=11)
                at ../sysdeps/unix/sysv/linux/pthread_kill.c:57
            [Current thread is 1 (Thread 0x153fb07bf700 (LWP 2786324))]
            (gdb) bt
            #0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=11) at ../sysdeps/unix/sysv/linux/pthread_kill.c:57
            #1  0x000055dd1f7c4fb7 in my_write_core (sig=sig@entry=11) at /test/10.5_opt/mysys/stacktrace.c:424
            #2  0x000055dd1f1957da in handle_fatal_signal (sig=11) at /test/10.5_opt/sql/signal_handler.cc:330
            #3  <signal handler called>
            #4  best_extension_by_limited_search (join=join@entry=0x153f5e111700, remaining_tables=remaining_tables@entry=6, idx=idx@entry=2, record_count=record_count@entry=1000, read_time=425.708984375, search_depth=search_depth@entry=3, prune_level=prune_level@entry=0, use_cond_selectivity=use_cond_selectivity@entry=5) at /test/10.5_opt/sql/sql_select.cc:9619
            #5  0x000055dd1efd7666 in best_extension_by_limited_search (join=join@entry=0x153f5e111700, remaining_tables=remaining_tables@entry=14, idx=idx@entry=1, record_count=record_count@entry=100, read_time=24, search_depth=search_depth@entry=4, prune_level=prune_level@entry=0, use_cond_selectivity=use_cond_selectivity@entry=5) at /test/10.5_opt/sql/sql_select.cc:9621
            #6  0x000055dd1efd7666 in best_extension_by_limited_search (join=join@entry=0x153f5e111700, remaining_tables=remaining_tables@entry=15, idx=idx@entry=0, record_count=1, read_time=read_time@entry=0, search_depth=search_depth@entry=5, prune_level=prune_level@entry=0, use_cond_selectivity=5) at /test/10.5_opt/sql/sql_select.cc:9621
            #7  0x000055dd1efd799a in greedy_search (use_cond_selectivity=<optimized out>, prune_level=<optimized out>, search_depth=5, remaining_tables=15, join=0x153f5e111700) at /test/10.5_opt/sql/sql_select.cc:8738
            #8  choose_plan (join=join@entry=0x153f5e111700, join_tables=<optimized out>) at /test/10.5_opt/sql/sql_select.cc:8303
            #9  0x000055dd1eff84b2 in make_join_statistics (keyuse_array=0x153f5e1119f0, tables_list=@0x153f5e0e6020: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x153f5e147760, last = 0x153f5c7ed568, elements = 4}, <No data fields>}, join=0x153f5e111700) at /test/10.5_opt/sql/sql_select.cc:5543
            #10 JOIN::optimize_inner (this=this@entry=0x153f5e111700) at /test/10.5_opt/sql/sql_select.cc:2247
            #11 0x000055dd1eff8b23 in JOIN::optimize (this=this@entry=0x153f5e111700) at /test/10.5_opt/sql/sql_select.cc:1623
            #12 0x000055dd1eff8be7 in mysql_select (thd=thd@entry=0x153f5c000c18, tables=0x153f5e0e84a0, fields=@0x153f5e0e5f30: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x153f5c1e5b90, last = 0x153f5c60b988, elements = 50}, <No data fields>}, conds=0x0, og_num=<optimized out>, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=10814572544, result=0x153f5e0ea160, unit=0x153f5c004bf8, select_lex=0x153f5e0e5de0) at /test/10.5_opt/sql/sql_select.cc:4637
            #13 0x000055dd1eff95e1 in handle_select (thd=thd@entry=0x153f5c000c18, lex=lex@entry=0x153f5c004b30, result=result@entry=0x153f5e0ea160, setup_tables_done_option=setup_tables_done_option@entry=0) at /test/10.5_opt/sql/sql_select.cc:417
            #14 0x000055dd1ef9eb21 in execute_sqlcom_select (thd=thd@entry=0x153f5c000c18, all_tables=0x153f5e0e84a0) at /test/10.5_opt/sql/sql_parse.cc:6210
            #15 0x000055dd1ef9b201 in mysql_execute_command (thd=thd@entry=0x153f5c000c18) at /test/10.5_opt/sql/sql_parse.cc:3932
            #16 0x000055dd1efa1c5c in mysql_parse (thd=0x153f5c000c18, rawbuf=<optimized out>, length=116, parser_state=0x153fb07be470, is_com_multi=<optimized out>, is_next_command=<optimized out>) at /test/10.5_opt/sql/sql_parse.cc:7994
            #17 0x000055dd1ef96ef5 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x153f5c000c18, packet=packet@entry=0x153f5e0a6c89 "select * from (select * FROM t1  natural join t2) as t1 natural left join (select * FROM t1  natural join t4) as t34;", packet_length=packet_length@entry=117, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/10.5_opt/sql/sql_parse.cc:1867
            #18 0x000055dd1ef95214 in do_command (thd=0x153f5c000c18) at /test/10.5_opt/sql/sql_parse.cc:1348
            #19 0x000055dd1f08c141 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x55dd236b9d08, put_in_cache=put_in_cache@entry=true) at /test/10.5_opt/sql/sql_connect.cc:1410
            #20 0x000055dd1f08c4b4 in handle_one_connection (arg=arg@entry=0x55dd236b9d08) at /test/10.5_opt/sql/sql_connect.cc:1312
            #21 0x000055dd1f4006ea in pfs_spawn_thread (arg=0x55dd23635948) at /test/10.5_opt/storage/perfschema/pfs.cc:2201
            #22 0x0000153fb2f1a6db in start_thread (arg=0x153fb07bf700) at pthread_create.c:463
            #23 0x0000153fb2318a3f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
            

            Roel Roel Van de Paar added a comment - Also saw a slightly different stack. It may be that replaying via the C-connector instead of at the CLI generates a slightly different stack (notice the one less best_extension_by_limited_search) even if join_cache_level=3 remains the same. If so, it is interesting; why does the CLI seem to produce one extra best_extension_by_limited_search call? 10.5.6 7fba16d53fe3c2fa241434e1ff715e6a3789c79a Core was generated by `/test/MD031020-mariadb-10.5.6-linux-x86_64-opt/bin/mysqld --no-defaults --max_a'. Program terminated with signal SIGSEGV, Segmentation fault. #0 __pthread_kill (threadid=<optimized out>, signo=signo@entry=11) at ../sysdeps/unix/sysv/linux/pthread_kill.c:57 [Current thread is 1 (Thread 0x153fb07bf700 (LWP 2786324))] (gdb) bt #0 __pthread_kill (threadid=<optimized out>, signo=signo@entry=11) at ../sysdeps/unix/sysv/linux/pthread_kill.c:57 #1 0x000055dd1f7c4fb7 in my_write_core (sig=sig@entry=11) at /test/10.5_opt/mysys/stacktrace.c:424 #2 0x000055dd1f1957da in handle_fatal_signal (sig=11) at /test/10.5_opt/sql/signal_handler.cc:330 #3 <signal handler called> #4 best_extension_by_limited_search (join=join@entry=0x153f5e111700, remaining_tables=remaining_tables@entry=6, idx=idx@entry=2, record_count=record_count@entry=1000, read_time=425.708984375, search_depth=search_depth@entry=3, prune_level=prune_level@entry=0, use_cond_selectivity=use_cond_selectivity@entry=5) at /test/10.5_opt/sql/sql_select.cc:9619 #5 0x000055dd1efd7666 in best_extension_by_limited_search (join=join@entry=0x153f5e111700, remaining_tables=remaining_tables@entry=14, idx=idx@entry=1, record_count=record_count@entry=100, read_time=24, search_depth=search_depth@entry=4, prune_level=prune_level@entry=0, use_cond_selectivity=use_cond_selectivity@entry=5) at /test/10.5_opt/sql/sql_select.cc:9621 #6 0x000055dd1efd7666 in best_extension_by_limited_search (join=join@entry=0x153f5e111700, remaining_tables=remaining_tables@entry=15, idx=idx@entry=0, record_count=1, read_time=read_time@entry=0, search_depth=search_depth@entry=5, prune_level=prune_level@entry=0, use_cond_selectivity=5) at /test/10.5_opt/sql/sql_select.cc:9621 #7 0x000055dd1efd799a in greedy_search (use_cond_selectivity=<optimized out>, prune_level=<optimized out>, search_depth=5, remaining_tables=15, join=0x153f5e111700) at /test/10.5_opt/sql/sql_select.cc:8738 #8 choose_plan (join=join@entry=0x153f5e111700, join_tables=<optimized out>) at /test/10.5_opt/sql/sql_select.cc:8303 #9 0x000055dd1eff84b2 in make_join_statistics (keyuse_array=0x153f5e1119f0, tables_list=@0x153f5e0e6020: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x153f5e147760, last = 0x153f5c7ed568, elements = 4}, <No data fields>}, join=0x153f5e111700) at /test/10.5_opt/sql/sql_select.cc:5543 #10 JOIN::optimize_inner (this=this@entry=0x153f5e111700) at /test/10.5_opt/sql/sql_select.cc:2247 #11 0x000055dd1eff8b23 in JOIN::optimize (this=this@entry=0x153f5e111700) at /test/10.5_opt/sql/sql_select.cc:1623 #12 0x000055dd1eff8be7 in mysql_select (thd=thd@entry=0x153f5c000c18, tables=0x153f5e0e84a0, fields=@0x153f5e0e5f30: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x153f5c1e5b90, last = 0x153f5c60b988, elements = 50}, <No data fields>}, conds=0x0, og_num=<optimized out>, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=10814572544, result=0x153f5e0ea160, unit=0x153f5c004bf8, select_lex=0x153f5e0e5de0) at /test/10.5_opt/sql/sql_select.cc:4637 #13 0x000055dd1eff95e1 in handle_select (thd=thd@entry=0x153f5c000c18, lex=lex@entry=0x153f5c004b30, result=result@entry=0x153f5e0ea160, setup_tables_done_option=setup_tables_done_option@entry=0) at /test/10.5_opt/sql/sql_select.cc:417 #14 0x000055dd1ef9eb21 in execute_sqlcom_select (thd=thd@entry=0x153f5c000c18, all_tables=0x153f5e0e84a0) at /test/10.5_opt/sql/sql_parse.cc:6210 #15 0x000055dd1ef9b201 in mysql_execute_command (thd=thd@entry=0x153f5c000c18) at /test/10.5_opt/sql/sql_parse.cc:3932 #16 0x000055dd1efa1c5c in mysql_parse (thd=0x153f5c000c18, rawbuf=<optimized out>, length=116, parser_state=0x153fb07be470, is_com_multi=<optimized out>, is_next_command=<optimized out>) at /test/10.5_opt/sql/sql_parse.cc:7994 #17 0x000055dd1ef96ef5 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x153f5c000c18, packet=packet@entry=0x153f5e0a6c89 "select * from (select * FROM t1 natural join t2) as t1 natural left join (select * FROM t1 natural join t4) as t34;", packet_length=packet_length@entry=117, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/10.5_opt/sql/sql_parse.cc:1867 #18 0x000055dd1ef95214 in do_command (thd=0x153f5c000c18) at /test/10.5_opt/sql/sql_parse.cc:1348 #19 0x000055dd1f08c141 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x55dd236b9d08, put_in_cache=put_in_cache@entry=true) at /test/10.5_opt/sql/sql_connect.cc:1410 #20 0x000055dd1f08c4b4 in handle_one_connection (arg=arg@entry=0x55dd236b9d08) at /test/10.5_opt/sql/sql_connect.cc:1312 #21 0x000055dd1f4006ea in pfs_spawn_thread (arg=0x55dd23635948) at /test/10.5_opt/storage/perfschema/pfs.cc:2201 #22 0x0000153fb2f1a6db in start_thread (arg=0x153fb07bf700) at pthread_create.c:463 #23 0x0000153fb2318a3f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
            Roel Roel Van de Paar added a comment - - edited

            A slightly more reproducible form, with a shorter stack again, with this testcase:

            # Repeat 30-500 times
            DROP DATABASE test;
            CREATE DATABASE test;
            USE test;
            SET default_tmp_storage_engine=InnoDB;
            SET join_cache_level=3;
            SET default_storage_engine=Aria, default_storage_engine="HEAP", GLOBAL default_storage_engine="MERGE";
            CREATE TEMPORARY TABLE t AS SELECT * FROM mysql.user;
            CREATE TABLE t2 (c INT);
            SELECT * FROM (SELECT * FROM t NATURAL JOIN t2) AS a NATURAL JOIN (SELECT * FROM t NATURAL JOIN t2) AS b;
            

            Leads to:

            10.5.6 2bac9782aa81ad386beaf00eb126ccf2d15031a1 (Debug)

            Core was generated by `/test/MD150920-mariadb-10.5.6-linux-x86_64-dbg/bin/mysqld --no-defaults --core-'.
            Program terminated with signal SIGSEGV, Segmentation fault.
            #0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=11)
                at ../sysdeps/unix/sysv/linux/pthread_kill.c:57
            [Current thread is 1 (Thread 0x14884e0f2700 (LWP 868746))]
            (gdb) bt
            #0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=11) at ../sysdeps/unix/sysv/linux/pthread_kill.c:57
            #1  0x000056453a89c85a in my_write_core (sig=sig@entry=11) at /test/10.5_dbg/mysys/stacktrace.c:424
            #2  0x000056453a0633a9 in handle_fatal_signal (sig=11) at /test/10.5_dbg/sql/signal_handler.cc:330
            #3  <signal handler called>
            #4  0x0000564539e1c7ff in best_extension_by_limited_search (join=join@entry=0x14882a0f6fe0, remaining_tables=remaining_tables@entry=2, idx=idx@entry=3, record_count=record_count@entry=7, read_time=2.3999999999999999, search_depth=search_depth@entry=61, prune_level=prune_level@entry=1, use_cond_selectivity=use_cond_selectivity@entry=4) at /test/10.5_dbg/sql/sql_select.cc:9631
            #5  0x0000564539e1c85c in best_extension_by_limited_search (join=join@entry=0x14882a0f6fe0, remaining_tables=remaining_tables@entry=3, idx=idx@entry=2, record_count=record_count@entry=1, read_time=read_time@entry=0, search_depth=search_depth@entry=62, prune_level=prune_level@entry=1, use_cond_selectivity=use_cond_selectivity@entry=4) at /test/10.5_dbg/sql/sql_select.cc:9633
            #6  0x0000564539e1dcf0 in greedy_search (use_cond_selectivity=<optimized out>, prune_level=<optimized out>, search_depth=62, remaining_tables=3, join=0x14882a0f6fe0) at /test/10.5_dbg/sql/sql_select.cc:8750
            #7  choose_plan (join=join@entry=0x14882a0f6fe0, join_tables=<optimized out>) at /test/10.5_dbg/sql/sql_select.cc:8315
            #8  0x0000564539e2edbd in make_join_statistics (keyuse_array=0x14882a0f72d0, tables_list=<optimized out>, join=0x14882a0f6fe0) at /test/10.5_dbg/sql/sql_select.cc:5555
            #9  JOIN::optimize_inner (this=this@entry=0x14882a0f6fe0) at /test/10.5_dbg/sql/sql_select.cc:2247
            #10 0x0000564539e2f3b3 in JOIN::optimize (this=this@entry=0x14882a0f6fe0) at /test/10.5_dbg/sql/sql_select.cc:1623
            #11 0x0000564539e2fd40 in mysql_select (thd=thd@entry=0x14882a015088, tables=<optimized out>, fields=@0x14882a074328: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x14882a074788, last = 0x14882a111d60, elements = 48}, <No data fields>}, conds=0x0, og_num=0, order=<optimized out>, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x14882a079ec0, unit=0x14882a019220, select_lex=0x14882a0741d8) at /test/10.5_dbg/sql/sql_select.cc:4649
            #12 0x0000564539e300bc in handle_select (thd=thd@entry=0x14882a015088, lex=lex@entry=0x14882a019158, result=result@entry=0x14882a079ec0, setup_tables_done_option=setup_tables_done_option@entry=0) at /test/10.5_dbg/sql/sql_select.cc:417
            #13 0x0000564539db7348 in execute_sqlcom_select (thd=thd@entry=0x14882a015088, all_tables=0x14882a076b58) at /test/10.5_dbg/sql/sql_parse.cc:6210
            #14 0x0000564539db041c in mysql_execute_command (thd=thd@entry=0x14882a015088) at /test/10.5_dbg/sql/sql_parse.cc:3932
            #15 0x0000564539dbd324 in mysql_parse (thd=thd@entry=0x14882a015088, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x14884e0f1350, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/10.5_dbg/sql/sql_parse.cc:7994
            #16 0x0000564539da9d54 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x14882a015088, packet=packet@entry=0x14882a067089 "SELECT * FROM (SELECT * FROM t NATURAL JOIN t2) AS a NATURAL JOIN (SELECT * FROM t NATURAL JOIN t2) AS b", packet_length=packet_length@entry=104, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/10.5_dbg/sql/sql_parse.cc:1867
            #17 0x0000564539da853e in do_command (thd=0x14882a015088) at /test/10.5_dbg/sql/sql_parse.cc:1348
            #18 0x0000564539f07893 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x14882d0d4808, put_in_cache=put_in_cache@entry=true) at /test/10.5_dbg/sql/sql_connect.cc:1410
            #19 0x0000564539f07fb7 in handle_one_connection (arg=arg@entry=0x14882d0d4808) at /test/10.5_dbg/sql/sql_connect.cc:1312
            #20 0x000056453a3725c2 in pfs_spawn_thread (arg=0x14884ac46508) at /test/10.5_dbg/storage/perfschema/pfs.cc:2201
            #21 0x000014884d06b6db in start_thread (arg=0x14884e0f2700) at pthread_create.c:463
            #22 0x000014884c469a3f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
            

            10.5.6 2bac9782aa81ad386beaf00eb126ccf2d15031a1 (Optimized)

            Core was generated by `/test/MD150920-mariadb-10.5.6-linux-x86_64-opt/bin/mysqld --no-defaults --core-'.
            Program terminated with signal SIGSEGV, Segmentation fault.
            #0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=11)
                at ../sysdeps/unix/sysv/linux/pthread_kill.c:57
            [Current thread is 1 (Thread 0x1522da745700 (LWP 881067))]
            (gdb) bt
            #0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=11) at ../sysdeps/unix/sysv/linux/pthread_kill.c:57
            #1  0x000055d52485aae7 in my_write_core (sig=sig@entry=11) at /data/10.5_opt/mysys/stacktrace.c:424
            #2  0x000055d524229fda in handle_fatal_signal (sig=11) at /data/10.5_opt/sql/signal_handler.cc:330
            #3  <signal handler called>
            #4  best_extension_by_limited_search (join=join@entry=0x1522b345df70, remaining_tables=remaining_tables@entry=2, idx=idx@entry=3, record_count=record_count@entry=7, read_time=2.3999999999999999, search_depth=search_depth@entry=61, prune_level=prune_level@entry=1, use_cond_selectivity=use_cond_selectivity@entry=4) at /data/10.5_opt/sql/sql_select.cc:9631
            #5  0x000055d52406c046 in best_extension_by_limited_search (join=join@entry=0x1522b345df70, remaining_tables=remaining_tables@entry=3, idx=idx@entry=2, record_count=1, read_time=read_time@entry=0, search_depth=search_depth@entry=62, prune_level=prune_level@entry=1, use_cond_selectivity=4) at /data/10.5_opt/sql/sql_select.cc:9633
            #6  0x000055d52406c37a in greedy_search (use_cond_selectivity=<optimized out>, prune_level=<optimized out>, search_depth=62, remaining_tables=3, join=0x1522b345df70) at /data/10.5_opt/sql/sql_select.cc:8750
            #7  choose_plan (join=join@entry=0x1522b345df70, join_tables=<optimized out>) at /data/10.5_opt/sql/sql_select.cc:8315
            #8  0x000055d52408cec2 in make_join_statistics (keyuse_array=0x1522b345e260, tables_list=@0x1522b34473a8: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x1522b35346e8, last = 0x1522b352af28, elements = 4}, <No data fields>}, join=0x1522b345df70) at /data/10.5_opt/sql/sql_select.cc:5555
            #9  JOIN::optimize_inner (this=this@entry=0x1522b345df70) at /data/10.5_opt/sql/sql_select.cc:2247
            #10 0x000055d52408d533 in JOIN::optimize (this=this@entry=0x1522b345df70) at /data/10.5_opt/sql/sql_select.cc:1623
            #11 0x000055d52408d631 in mysql_select (thd=thd@entry=0x1522b3412018, tables=0x1522b3449ae8, fields=@0x1522b34472b8: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x1522b3447718, last = 0x1522b358ecf0, elements = 48}, <No data fields>}, conds=0x0, og_num=<optimized out>, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x1522b344ce50, unit=0x1522b3415ff0, select_lex=0x1522b3447168) at /data/10.5_opt/sql/sql_select.cc:4649
            #12 0x000055d52408e041 in handle_select (thd=thd@entry=0x1522b3412018, lex=lex@entry=0x1522b3415f28, result=result@entry=0x1522b344ce50, setup_tables_done_option=setup_tables_done_option@entry=0) at /data/10.5_opt/sql/sql_select.cc:417
            #13 0x000055d5240338f1 in execute_sqlcom_select (thd=thd@entry=0x1522b3412018, all_tables=0x1522b3449ae8) at /data/10.5_opt/sql/sql_parse.cc:6210
            #14 0x000055d52402ffd1 in mysql_execute_command (thd=thd@entry=0x1522b3412018) at /data/10.5_opt/sql/sql_parse.cc:3932
            #15 0x000055d524036a2c in mysql_parse (thd=0x1522b3412018, rawbuf=<optimized out>, length=104, parser_state=0x1522da744430, is_com_multi=<optimized out>, is_next_command=<optimized out>) at /data/10.5_opt/sql/sql_parse.cc:7994
            #16 0x000055d52402bcc5 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x1522b3412018, packet=packet@entry=0x1522b343a019 "SELECT * FROM (SELECT * FROM t NATURAL JOIN t2) AS a NATURAL JOIN (SELECT * FROM t NATURAL JOIN t2) AS b", packet_length=packet_length@entry=104, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /data/10.5_opt/sql/sql_parse.cc:1867
            #17 0x000055d524029fe4 in do_command (thd=0x1522b3412018) at /data/10.5_opt/sql/sql_parse.cc:1348
            #18 0x000055d524120ba1 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x1522d74338f8, put_in_cache=put_in_cache@entry=true) at /data/10.5_opt/sql/sql_connect.cc:1410
            #19 0x000055d524120f14 in handle_one_connection (arg=arg@entry=0x1522d74338f8) at /data/10.5_opt/sql/sql_connect.cc:1312
            #20 0x000055d524494a4a in pfs_spawn_thread (arg=0x1522d744f018) at /data/10.5_opt/storage/perfschema/pfs.cc:2201
            #21 0x00001522d96be6db in start_thread (arg=0x1522da745700) at pthread_create.c:463
            #22 0x00001522d8abca3f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
            

            Bug confirmed present in:
            MariaDB: 10.4.15 (dbg), 10.4.15 (opt), 10.5.6 (dbg), 10.5.6 (opt), 10.6.0 (dbg), 10.6.0 (opt)

            Bug confirmed not present in:
            MariaDB: 10.1.47 (dbg), 10.1.47 (opt), 10.2.34 (dbg), 10.2.34 (opt), 10.3.25 (dbg), 10.3.25 (opt)
            MySQL: 5.5.62 (dbg), 5.5.62 (opt), 5.6.49 (dbg), 5.6.49 (opt), 5.7.31 (dbg), 5.7.31 (opt), 8.0.21 (dbg), 8.0.21 (opt)

            Roel Roel Van de Paar added a comment - - edited A slightly more reproducible form, with a shorter stack again, with this testcase: # Repeat 30-500 times DROP DATABASE test; CREATE DATABASE test; USE test; SET default_tmp_storage_engine=InnoDB; SET join_cache_level=3; SET default_storage_engine=Aria, default_storage_engine="HEAP", GLOBAL default_storage_engine="MERGE"; CREATE TEMPORARY TABLE t AS SELECT * FROM mysql.user; CREATE TABLE t2 (c INT); SELECT * FROM (SELECT * FROM t NATURAL JOIN t2) AS a NATURAL JOIN (SELECT * FROM t NATURAL JOIN t2) AS b; Leads to: 10.5.6 2bac9782aa81ad386beaf00eb126ccf2d15031a1 (Debug) Core was generated by `/test/MD150920-mariadb-10.5.6-linux-x86_64-dbg/bin/mysqld --no-defaults --core-'. Program terminated with signal SIGSEGV, Segmentation fault. #0 __pthread_kill (threadid=<optimized out>, signo=signo@entry=11) at ../sysdeps/unix/sysv/linux/pthread_kill.c:57 [Current thread is 1 (Thread 0x14884e0f2700 (LWP 868746))] (gdb) bt #0 __pthread_kill (threadid=<optimized out>, signo=signo@entry=11) at ../sysdeps/unix/sysv/linux/pthread_kill.c:57 #1 0x000056453a89c85a in my_write_core (sig=sig@entry=11) at /test/10.5_dbg/mysys/stacktrace.c:424 #2 0x000056453a0633a9 in handle_fatal_signal (sig=11) at /test/10.5_dbg/sql/signal_handler.cc:330 #3 <signal handler called> #4 0x0000564539e1c7ff in best_extension_by_limited_search (join=join@entry=0x14882a0f6fe0, remaining_tables=remaining_tables@entry=2, idx=idx@entry=3, record_count=record_count@entry=7, read_time=2.3999999999999999, search_depth=search_depth@entry=61, prune_level=prune_level@entry=1, use_cond_selectivity=use_cond_selectivity@entry=4) at /test/10.5_dbg/sql/sql_select.cc:9631 #5 0x0000564539e1c85c in best_extension_by_limited_search (join=join@entry=0x14882a0f6fe0, remaining_tables=remaining_tables@entry=3, idx=idx@entry=2, record_count=record_count@entry=1, read_time=read_time@entry=0, search_depth=search_depth@entry=62, prune_level=prune_level@entry=1, use_cond_selectivity=use_cond_selectivity@entry=4) at /test/10.5_dbg/sql/sql_select.cc:9633 #6 0x0000564539e1dcf0 in greedy_search (use_cond_selectivity=<optimized out>, prune_level=<optimized out>, search_depth=62, remaining_tables=3, join=0x14882a0f6fe0) at /test/10.5_dbg/sql/sql_select.cc:8750 #7 choose_plan (join=join@entry=0x14882a0f6fe0, join_tables=<optimized out>) at /test/10.5_dbg/sql/sql_select.cc:8315 #8 0x0000564539e2edbd in make_join_statistics (keyuse_array=0x14882a0f72d0, tables_list=<optimized out>, join=0x14882a0f6fe0) at /test/10.5_dbg/sql/sql_select.cc:5555 #9 JOIN::optimize_inner (this=this@entry=0x14882a0f6fe0) at /test/10.5_dbg/sql/sql_select.cc:2247 #10 0x0000564539e2f3b3 in JOIN::optimize (this=this@entry=0x14882a0f6fe0) at /test/10.5_dbg/sql/sql_select.cc:1623 #11 0x0000564539e2fd40 in mysql_select (thd=thd@entry=0x14882a015088, tables=<optimized out>, fields=@0x14882a074328: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x14882a074788, last = 0x14882a111d60, elements = 48}, <No data fields>}, conds=0x0, og_num=0, order=<optimized out>, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x14882a079ec0, unit=0x14882a019220, select_lex=0x14882a0741d8) at /test/10.5_dbg/sql/sql_select.cc:4649 #12 0x0000564539e300bc in handle_select (thd=thd@entry=0x14882a015088, lex=lex@entry=0x14882a019158, result=result@entry=0x14882a079ec0, setup_tables_done_option=setup_tables_done_option@entry=0) at /test/10.5_dbg/sql/sql_select.cc:417 #13 0x0000564539db7348 in execute_sqlcom_select (thd=thd@entry=0x14882a015088, all_tables=0x14882a076b58) at /test/10.5_dbg/sql/sql_parse.cc:6210 #14 0x0000564539db041c in mysql_execute_command (thd=thd@entry=0x14882a015088) at /test/10.5_dbg/sql/sql_parse.cc:3932 #15 0x0000564539dbd324 in mysql_parse (thd=thd@entry=0x14882a015088, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x14884e0f1350, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/10.5_dbg/sql/sql_parse.cc:7994 #16 0x0000564539da9d54 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x14882a015088, packet=packet@entry=0x14882a067089 "SELECT * FROM (SELECT * FROM t NATURAL JOIN t2) AS a NATURAL JOIN (SELECT * FROM t NATURAL JOIN t2) AS b", packet_length=packet_length@entry=104, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/10.5_dbg/sql/sql_parse.cc:1867 #17 0x0000564539da853e in do_command (thd=0x14882a015088) at /test/10.5_dbg/sql/sql_parse.cc:1348 #18 0x0000564539f07893 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x14882d0d4808, put_in_cache=put_in_cache@entry=true) at /test/10.5_dbg/sql/sql_connect.cc:1410 #19 0x0000564539f07fb7 in handle_one_connection (arg=arg@entry=0x14882d0d4808) at /test/10.5_dbg/sql/sql_connect.cc:1312 #20 0x000056453a3725c2 in pfs_spawn_thread (arg=0x14884ac46508) at /test/10.5_dbg/storage/perfschema/pfs.cc:2201 #21 0x000014884d06b6db in start_thread (arg=0x14884e0f2700) at pthread_create.c:463 #22 0x000014884c469a3f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95 10.5.6 2bac9782aa81ad386beaf00eb126ccf2d15031a1 (Optimized) Core was generated by `/test/MD150920-mariadb-10.5.6-linux-x86_64-opt/bin/mysqld --no-defaults --core-'. Program terminated with signal SIGSEGV, Segmentation fault. #0 __pthread_kill (threadid=<optimized out>, signo=signo@entry=11) at ../sysdeps/unix/sysv/linux/pthread_kill.c:57 [Current thread is 1 (Thread 0x1522da745700 (LWP 881067))] (gdb) bt #0 __pthread_kill (threadid=<optimized out>, signo=signo@entry=11) at ../sysdeps/unix/sysv/linux/pthread_kill.c:57 #1 0x000055d52485aae7 in my_write_core (sig=sig@entry=11) at /data/10.5_opt/mysys/stacktrace.c:424 #2 0x000055d524229fda in handle_fatal_signal (sig=11) at /data/10.5_opt/sql/signal_handler.cc:330 #3 <signal handler called> #4 best_extension_by_limited_search (join=join@entry=0x1522b345df70, remaining_tables=remaining_tables@entry=2, idx=idx@entry=3, record_count=record_count@entry=7, read_time=2.3999999999999999, search_depth=search_depth@entry=61, prune_level=prune_level@entry=1, use_cond_selectivity=use_cond_selectivity@entry=4) at /data/10.5_opt/sql/sql_select.cc:9631 #5 0x000055d52406c046 in best_extension_by_limited_search (join=join@entry=0x1522b345df70, remaining_tables=remaining_tables@entry=3, idx=idx@entry=2, record_count=1, read_time=read_time@entry=0, search_depth=search_depth@entry=62, prune_level=prune_level@entry=1, use_cond_selectivity=4) at /data/10.5_opt/sql/sql_select.cc:9633 #6 0x000055d52406c37a in greedy_search (use_cond_selectivity=<optimized out>, prune_level=<optimized out>, search_depth=62, remaining_tables=3, join=0x1522b345df70) at /data/10.5_opt/sql/sql_select.cc:8750 #7 choose_plan (join=join@entry=0x1522b345df70, join_tables=<optimized out>) at /data/10.5_opt/sql/sql_select.cc:8315 #8 0x000055d52408cec2 in make_join_statistics (keyuse_array=0x1522b345e260, tables_list=@0x1522b34473a8: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x1522b35346e8, last = 0x1522b352af28, elements = 4}, <No data fields>}, join=0x1522b345df70) at /data/10.5_opt/sql/sql_select.cc:5555 #9 JOIN::optimize_inner (this=this@entry=0x1522b345df70) at /data/10.5_opt/sql/sql_select.cc:2247 #10 0x000055d52408d533 in JOIN::optimize (this=this@entry=0x1522b345df70) at /data/10.5_opt/sql/sql_select.cc:1623 #11 0x000055d52408d631 in mysql_select (thd=thd@entry=0x1522b3412018, tables=0x1522b3449ae8, fields=@0x1522b34472b8: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x1522b3447718, last = 0x1522b358ecf0, elements = 48}, <No data fields>}, conds=0x0, og_num=<optimized out>, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x1522b344ce50, unit=0x1522b3415ff0, select_lex=0x1522b3447168) at /data/10.5_opt/sql/sql_select.cc:4649 #12 0x000055d52408e041 in handle_select (thd=thd@entry=0x1522b3412018, lex=lex@entry=0x1522b3415f28, result=result@entry=0x1522b344ce50, setup_tables_done_option=setup_tables_done_option@entry=0) at /data/10.5_opt/sql/sql_select.cc:417 #13 0x000055d5240338f1 in execute_sqlcom_select (thd=thd@entry=0x1522b3412018, all_tables=0x1522b3449ae8) at /data/10.5_opt/sql/sql_parse.cc:6210 #14 0x000055d52402ffd1 in mysql_execute_command (thd=thd@entry=0x1522b3412018) at /data/10.5_opt/sql/sql_parse.cc:3932 #15 0x000055d524036a2c in mysql_parse (thd=0x1522b3412018, rawbuf=<optimized out>, length=104, parser_state=0x1522da744430, is_com_multi=<optimized out>, is_next_command=<optimized out>) at /data/10.5_opt/sql/sql_parse.cc:7994 #16 0x000055d52402bcc5 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x1522b3412018, packet=packet@entry=0x1522b343a019 "SELECT * FROM (SELECT * FROM t NATURAL JOIN t2) AS a NATURAL JOIN (SELECT * FROM t NATURAL JOIN t2) AS b", packet_length=packet_length@entry=104, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /data/10.5_opt/sql/sql_parse.cc:1867 #17 0x000055d524029fe4 in do_command (thd=0x1522b3412018) at /data/10.5_opt/sql/sql_parse.cc:1348 #18 0x000055d524120ba1 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x1522d74338f8, put_in_cache=put_in_cache@entry=true) at /data/10.5_opt/sql/sql_connect.cc:1410 #19 0x000055d524120f14 in handle_one_connection (arg=arg@entry=0x1522d74338f8) at /data/10.5_opt/sql/sql_connect.cc:1312 #20 0x000055d524494a4a in pfs_spawn_thread (arg=0x1522d744f018) at /data/10.5_opt/storage/perfschema/pfs.cc:2201 #21 0x00001522d96be6db in start_thread (arg=0x1522da745700) at pthread_create.c:463 #22 0x00001522d8abca3f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95 Bug confirmed present in: MariaDB: 10.4.15 (dbg), 10.4.15 (opt), 10.5.6 (dbg), 10.5.6 (opt), 10.6.0 (dbg), 10.6.0 (opt) Bug confirmed not present in: MariaDB: 10.1.47 (dbg), 10.1.47 (opt), 10.2.34 (dbg), 10.2.34 (opt), 10.3.25 (dbg), 10.3.25 (opt) MySQL: 5.5.62 (dbg), 5.5.62 (opt), 5.6.49 (dbg), 5.6.49 (opt), 5.7.31 (dbg), 5.7.31 (opt), 8.0.21 (dbg), 8.0.21 (opt)

            Smaller testcase to reproduce the problem

            --source include/have_sequence.inc
            SET SESSION join_cache_level=3;
            set optimizer_use_condition_selectivity=2;
            CREATE TABLE t1 AS SELECT * FROM mysql.user;
            CREATE TABLE t3 (b VARCHAR (1));
            CREATE TABLE t2 (c2 INT);
            INSERT INTO t2 VALUES (1);
             
            EXPLAIN
            SELECT * FROM t1 AS a NATURAL JOIN t1 AS b;
             
            DROP TABLE t1,t2,t3;
            

            This is also reproducible on earlier versions

            varun Varun Gupta (Inactive) added a comment - Smaller testcase to reproduce the problem --source include/have_sequence.inc SET SESSION join_cache_level=3; set optimizer_use_condition_selectivity=2; CREATE TABLE t1 AS SELECT * FROM mysql. user ; CREATE TABLE t3 (b VARCHAR (1)); CREATE TABLE t2 (c2 INT ); INSERT INTO t2 VALUES (1);   EXPLAIN SELECT * FROM t1 AS a NATURAL JOIN t1 AS b;   DROP TABLE t1,t2,t3; This is also reproducible on earlier versions

            Looks like a duplicate to https://jira.mariadb.org/browse/MDEV-17783 to me.

            varun Varun Gupta (Inactive) added a comment - Looks like a duplicate to https://jira.mariadb.org/browse/MDEV-17783 to me.
            Roel Roel Van de Paar added a comment - - edited

            Found another stack trace. Making small changes to the testcase results in original stack. Seems to generally require only 1 execution, but more may be needed.

            SET GLOBAL optimizer_search_depth = 1;
            SET SESSION join_cache_level=8;
            CREATE TABLE t1 AS SELECT * FROM mysql.user LIMIT 0;
            CREATE TABLE t2 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b VARCHAR(1));
            CREATE TABLE t4 (f1 INT);
            SET SESSION optimizer_search_depth=DEFAULT;
            SELECT * FROM (SELECT * FROM t1 NATURAL JOIN t2) AS t1 NATURAL JOIN (SELECT * FROM t1 NATURAL JOIN t4) AS t34;
            

            Leads to:

            10.6.0 c3d4e5718262c0e385f641fbed055b00397fcbf6(Optimized)

            Core was generated by `/test/MD201120-mariadb-10.6.0-linux-x86_64-opt/bin/mysqld --no-defaults --core-'.
            Program terminated with signal SIGSEGV, Segmentation fault.
            #0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=11)
                at ../sysdeps/unix/sysv/linux/pthread_kill.c:56
            [Current thread is 1 (Thread 0x149cd8517700 (LWP 975216))]
            (gdb) bt
            #0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=11) at ../sysdeps/unix/sysv/linux/pthread_kill.c:56
            #1  0x000055aee03c4c5f in my_write_core (sig=sig@entry=11) at /test/10.6_opt/mysys/stacktrace.c:424
            #2  0x000055aedfdf5550 in handle_fatal_signal (sig=11) at /test/10.6_opt/sql/signal_handler.cc:330
            #3  <signal handler called>
            #4  restore_prev_nj_state (last=<optimized out>, last=<optimized out>) at /test/10.6_opt/sql/sql_select.cc:9678
            #5  best_extension_by_limited_search (join=0x149c9c06f900, remaining_tables=10, idx=2, record_count=1, read_time=2.3999999999999999, search_depth=1, prune_level=1, use_cond_selectivity=4) at /test/10.6_opt/sql/sql_select.cc:9678
            #6  0x000055aedfc232f0 in greedy_search (use_cond_selectivity=<optimized out>, prune_level=1, search_depth=1, remaining_tables=10, join=0x149c9c06f900) at /test/10.6_opt/sql/sql_select.cc:8752
            #7  choose_plan (join=0x149c9c06f900, join_tables=<optimized out>) at /test/10.6_opt/sql/sql_select.cc:8317
            #8  0x000055aedfc504a9 in make_join_statistics (keyuse_array=0x149c9c06fbf0, tables_list=@0x149c9c010730: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x149c9c029958, last = 0x149c9c080258, elements = 4}, <No data fields>}, join=0x149c9c06f900) at /test/10.6_opt/sql/sql_select.cc:5557
            #9  JOIN::optimize_inner (this=0x149c9c06f900) at /test/10.6_opt/sql/sql_select.cc:2251
            #10 0x000055aedfc50a83 in JOIN::optimize (this=this@entry=0x149c9c06f900) at /test/10.6_opt/sql/sql_select.cc:1627
            #11 0x000055aedfc50b47 in mysql_select (thd=0x149c9c000c58, tables=0x149c9c012e60, fields=<optimized out>, conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x149c9c0161a0, unit=0x149c9c004c28, select_lex=0x149c9c0104f0) at /test/10.6_opt/sql/sql_select.cc:4651
            #12 0x000055aedfc51567 in handle_select (thd=thd@entry=0x149c9c000c58, lex=lex@entry=0x149c9c004b60, result=result@entry=0x149c9c0161a0, setup_tables_done_option=setup_tables_done_option@entry=0) at /test/10.6_opt/sql/sql_select.cc:417
            #13 0x000055aedfbe0551 in execute_sqlcom_select (thd=0x149c9c000c58, all_tables=0x149c9c012e60) at /test/10.6_opt/sql/sql_parse.cc:6118
            #14 0x000055aedfbee243 in mysql_execute_command (thd=0x149c9c000c58) at /test/10.6_opt/sql/sql_parse.cc:3820
            #15 0x000055aedfbdaeff in mysql_parse (thd=0x149c9c000c58, rawbuf=<optimized out>, length=<optimized out>, parser_state=<optimized out>) at /test/10.6_opt/sql/sql_parse.cc:7883
            #16 0x000055aedfbe6857 in dispatch_command (command=COM_QUERY, thd=0x149c9c000c58, packet=0x149c9c008019 "SELECT * FROM (SELECT * FROM t1 NATURAL JOIN t2) AS t1 NATURAL JOIN (SELECT * FROM t1 NATURAL JOIN t4) AS t34", packet_length=<optimized out>) at /test/10.6_opt/sql/sql_class.h:1254
            #17 0x000055aedfbe8c32 in do_command (thd=0x149c9c000c58) at /test/10.6_opt/sql/sql_parse.cc:1348
            #18 0x000055aedfced801 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x55aee32f5178, put_in_cache=put_in_cache@entry=true) at /test/10.6_opt/sql/sql_connect.cc:1410
            #19 0x000055aedfcedc7d in handle_one_connection (arg=arg@entry=0x55aee32f5178) at /test/10.6_opt/sql/sql_connect.cc:1312
            #20 0x000055aee0073726 in pfs_spawn_thread (arg=0x55aee32711d8) at /test/10.6_opt/storage/perfschema/pfs.cc:2201
            #21 0x0000149cee892609 in start_thread (arg=<optimized out>) at pthread_create.c:477
            #22 0x0000149cee481293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
            

            Bug confirmed present in:
            MariaDB: 10.4.16 (dbg), 10.4.16 (opt), 10.5.7 (dbg), 10.5.7 (opt), 10.6.0 (dbg), 10.6.0 (opt)

            Bug confirmed not present in:
            MariaDB: 10.1.48 (dbg), 10.1.48 (opt), 10.2.35 (dbg), 10.2.35 (opt), 10.3.26 (dbg), 10.3.26 (opt)
            MySQL: 5.5.62 (dbg), 5.5.62 (opt), 5.6.50 (dbg), 5.6.50 (opt), 5.7.32 (dbg), 5.7.32 (opt), 8.0.22 (dbg), 8.0.22 (opt)

            Roel Roel Van de Paar added a comment - - edited Found another stack trace. Making small changes to the testcase results in original stack. Seems to generally require only 1 execution, but more may be needed. SET GLOBAL optimizer_search_depth = 1; SET SESSION join_cache_level=8; CREATE TABLE t1 AS SELECT * FROM mysql.user LIMIT 0; CREATE TABLE t2 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b VARCHAR(1)); CREATE TABLE t4 (f1 INT); SET SESSION optimizer_search_depth=DEFAULT; SELECT * FROM (SELECT * FROM t1 NATURAL JOIN t2) AS t1 NATURAL JOIN (SELECT * FROM t1 NATURAL JOIN t4) AS t34; Leads to: 10.6.0 c3d4e5718262c0e385f641fbed055b00397fcbf6(Optimized) Core was generated by `/test/MD201120-mariadb-10.6.0-linux-x86_64-opt/bin/mysqld --no-defaults --core-'. Program terminated with signal SIGSEGV, Segmentation fault. #0 __pthread_kill (threadid=<optimized out>, signo=signo@entry=11) at ../sysdeps/unix/sysv/linux/pthread_kill.c:56 [Current thread is 1 (Thread 0x149cd8517700 (LWP 975216))] (gdb) bt #0 __pthread_kill (threadid=<optimized out>, signo=signo@entry=11) at ../sysdeps/unix/sysv/linux/pthread_kill.c:56 #1 0x000055aee03c4c5f in my_write_core (sig=sig@entry=11) at /test/10.6_opt/mysys/stacktrace.c:424 #2 0x000055aedfdf5550 in handle_fatal_signal (sig=11) at /test/10.6_opt/sql/signal_handler.cc:330 #3 <signal handler called> #4 restore_prev_nj_state (last=<optimized out>, last=<optimized out>) at /test/10.6_opt/sql/sql_select.cc:9678 #5 best_extension_by_limited_search (join=0x149c9c06f900, remaining_tables=10, idx=2, record_count=1, read_time=2.3999999999999999, search_depth=1, prune_level=1, use_cond_selectivity=4) at /test/10.6_opt/sql/sql_select.cc:9678 #6 0x000055aedfc232f0 in greedy_search (use_cond_selectivity=<optimized out>, prune_level=1, search_depth=1, remaining_tables=10, join=0x149c9c06f900) at /test/10.6_opt/sql/sql_select.cc:8752 #7 choose_plan (join=0x149c9c06f900, join_tables=<optimized out>) at /test/10.6_opt/sql/sql_select.cc:8317 #8 0x000055aedfc504a9 in make_join_statistics (keyuse_array=0x149c9c06fbf0, tables_list=@0x149c9c010730: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x149c9c029958, last = 0x149c9c080258, elements = 4}, <No data fields>}, join=0x149c9c06f900) at /test/10.6_opt/sql/sql_select.cc:5557 #9 JOIN::optimize_inner (this=0x149c9c06f900) at /test/10.6_opt/sql/sql_select.cc:2251 #10 0x000055aedfc50a83 in JOIN::optimize (this=this@entry=0x149c9c06f900) at /test/10.6_opt/sql/sql_select.cc:1627 #11 0x000055aedfc50b47 in mysql_select (thd=0x149c9c000c58, tables=0x149c9c012e60, fields=<optimized out>, conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x149c9c0161a0, unit=0x149c9c004c28, select_lex=0x149c9c0104f0) at /test/10.6_opt/sql/sql_select.cc:4651 #12 0x000055aedfc51567 in handle_select (thd=thd@entry=0x149c9c000c58, lex=lex@entry=0x149c9c004b60, result=result@entry=0x149c9c0161a0, setup_tables_done_option=setup_tables_done_option@entry=0) at /test/10.6_opt/sql/sql_select.cc:417 #13 0x000055aedfbe0551 in execute_sqlcom_select (thd=0x149c9c000c58, all_tables=0x149c9c012e60) at /test/10.6_opt/sql/sql_parse.cc:6118 #14 0x000055aedfbee243 in mysql_execute_command (thd=0x149c9c000c58) at /test/10.6_opt/sql/sql_parse.cc:3820 #15 0x000055aedfbdaeff in mysql_parse (thd=0x149c9c000c58, rawbuf=<optimized out>, length=<optimized out>, parser_state=<optimized out>) at /test/10.6_opt/sql/sql_parse.cc:7883 #16 0x000055aedfbe6857 in dispatch_command (command=COM_QUERY, thd=0x149c9c000c58, packet=0x149c9c008019 "SELECT * FROM (SELECT * FROM t1 NATURAL JOIN t2) AS t1 NATURAL JOIN (SELECT * FROM t1 NATURAL JOIN t4) AS t34", packet_length=<optimized out>) at /test/10.6_opt/sql/sql_class.h:1254 #17 0x000055aedfbe8c32 in do_command (thd=0x149c9c000c58) at /test/10.6_opt/sql/sql_parse.cc:1348 #18 0x000055aedfced801 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x55aee32f5178, put_in_cache=put_in_cache@entry=true) at /test/10.6_opt/sql/sql_connect.cc:1410 #19 0x000055aedfcedc7d in handle_one_connection (arg=arg@entry=0x55aee32f5178) at /test/10.6_opt/sql/sql_connect.cc:1312 #20 0x000055aee0073726 in pfs_spawn_thread (arg=0x55aee32711d8) at /test/10.6_opt/storage/perfschema/pfs.cc:2201 #21 0x0000149cee892609 in start_thread (arg=<optimized out>) at pthread_create.c:477 #22 0x0000149cee481293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95 Bug confirmed present in: MariaDB: 10.4.16 (dbg), 10.4.16 (opt), 10.5.7 (dbg), 10.5.7 (opt), 10.6.0 (dbg), 10.6.0 (opt) Bug confirmed not present in: MariaDB: 10.1.48 (dbg), 10.1.48 (opt), 10.2.35 (dbg), 10.2.35 (opt), 10.3.26 (dbg), 10.3.26 (opt) MySQL: 5.5.62 (dbg), 5.5.62 (opt), 5.6.50 (dbg), 5.6.50 (opt), 5.7.32 (dbg), 5.7.32 (opt), 8.0.22 (dbg), 8.0.22 (opt)

            varun Thank you. There is still a regression somewhere it seems as some testcases only crash 10.4, 10.5, 10.6?

            Roel Roel Van de Paar added a comment - varun Thank you. There is still a regression somewhere it seems as some testcases only crash 10.4, 10.5, 10.6?
            Roel Roel Van de Paar added a comment - - edited

            Found yet another stack. Testcase looks to be non-sporadic.

            SET join_cache_level=8;
            CREATE TEMPORARY TABLE t AS SELECT * FROM mysql.user;
            CREATE TEMPORARY TABLE t2 LIKE t;
            SELECT t.*,t2.* FROM t NATURAL JOIN t2;
            

            Leads to:

            10.6.1 f8665314d4ba190679001b81bb7d9fd7a38fc0f6 (Debug)

            Core was generated by `/test/MD100521-mariadb-10.6.1-linux-x86_64-dbg/bin/mysqld --no-defaults --core-'.
            Program terminated with signal SIGSEGV, Segmentation fault.
            #0  restore_prev_nj_state (last=last@entry=0x1000100010001)
                at /test/10.6_dbg/sql/sql_select.cc:17096
            17096	  TABLE_LIST *last_emb= last->table->pos_in_table_list->embedding;
            [Current thread is 1 (Thread 0x152900565700 (LWP 3239121))]
            (gdb) bt
            #0  restore_prev_nj_state (last=last@entry=0x1000100010001) at /test/10.6_dbg/sql/sql_select.cc:17096
            #1  0x0000558ff34356e9 in best_extension_by_limited_search (join=join@entry=0x1528c40166c8, remaining_tables=remaining_tables@entry=1, idx=idx@entry=1, record_count=record_count@entry=1, read_time=1.2, search_depth=search_depth@entry=61, prune_level=prune_level@entry=1, use_cond_selectivity=use_cond_selectivity@entry=4) at /test/10.6_dbg/sql/sql_select.cc:9880
            #2  0x0000558ff343557c in best_extension_by_limited_search (join=join@entry=0x1528c40166c8, remaining_tables=remaining_tables@entry=3, idx=idx@entry=0, record_count=record_count@entry=1, read_time=read_time@entry=0, search_depth=search_depth@entry=62, prune_level=prune_level@entry=1, use_cond_selectivity=use_cond_selectivity@entry=4) at /test/10.6_dbg/sql/sql_select.cc:9837
            #3  0x0000558ff343683b in greedy_search (use_cond_selectivity=<optimized out>, prune_level=<optimized out>, search_depth=62, remaining_tables=3, join=0x1528c40166c8) at /test/10.6_dbg/sql/sql_select.cc:8954
            #4  choose_plan (join=join@entry=0x1528c40166c8, join_tables=<optimized out>) at /test/10.6_dbg/sql/sql_select.cc:8519
            #5  0x0000558ff346613b in make_join_statistics (join=join@entry=0x1528c40166c8, tables_list=@0x1528c40142d0: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x1528c4016c68, last = 0x1528c4016c78, elements = 2}, <No data fields>}, keyuse_array=keyuse_array@entry=0x1528c40169e0) at /test/10.6_dbg/sql/sql_select.cc:5758
            #6  0x0000558ff346d295 in JOIN::optimize_inner (this=this@entry=0x1528c40166c8) at /test/10.6_dbg/sql/sql_select.cc:2336
            #7  0x0000558ff346d560 in JOIN::optimize (this=this@entry=0x1528c40166c8) at /test/10.6_dbg/sql/sql_select.cc:1705
            #8  0x0000558ff346df29 in mysql_select (thd=thd@entry=0x1528c4000db8, tables=0x1528c4014808, fields=@0x1528c40141e0: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x1528c4014668, last = 0x1528c40a0b88, elements = 94}, <No data fields>}, conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x1528c40166a0, unit=0x1528c4005120, select_lex=0x1528c4014088) at /test/10.6_dbg/sql/sql_select.cc:4851
            #9  0x0000558ff346e23e in handle_select (thd=thd@entry=0x1528c4000db8, lex=lex@entry=0x1528c4005058, result=result@entry=0x1528c40166a0, setup_tables_done_option=setup_tables_done_option@entry=0) at /test/10.6_dbg/sql/sql_select.cc:446
            #10 0x0000558ff33e0eff in execute_sqlcom_select (thd=thd@entry=0x1528c4000db8, all_tables=0x1528c4014808) at /test/10.6_dbg/sql/sql_parse.cc:6244
            #11 0x0000558ff33eddf8 in mysql_execute_command (thd=thd@entry=0x1528c4000db8) at /test/10.6_dbg/sql/sql_parse.cc:3940
            #12 0x0000558ff33da02b in mysql_parse (thd=thd@entry=0x1528c4000db8, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x152900564410) at /test/10.6_dbg/sql/sql_parse.cc:8018
            #13 0x0000558ff33e8e5d in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x1528c4000db8, packet=packet@entry=0x1528c400b799 "SELECT t.*,t2.* FROM t NATURAL JOIN t2", packet_length=packet_length@entry=38, blocking=blocking@entry=true) at /test/10.6_dbg/sql/sql_class.h:1333
            #14 0x0000558ff33ec250 in do_command (thd=0x1528c4000db8, blocking=blocking@entry=true) at /test/10.6_dbg/sql/sql_parse.cc:1406
            #15 0x0000558ff3546dec in do_handle_one_connection (connect=<optimized out>, connect@entry=0x558ff5a61028, put_in_cache=put_in_cache@entry=true) at /test/10.6_dbg/sql/sql_connect.cc:1410
            #16 0x0000558ff35473f1 in handle_one_connection (arg=arg@entry=0x558ff5a61028) at /test/10.6_dbg/sql/sql_connect.cc:1312
            #17 0x0000558ff39f9cee in pfs_spawn_thread (arg=0x558ff594a878) at /test/10.6_dbg/storage/perfschema/pfs.cc:2201
            #18 0x00001529178e0609 in start_thread (arg=<optimized out>) at pthread_create.c:477
            #19 0x00001529174cf293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
            

            Bug confirmed present in:
            MariaDB: 10.4.19 (dbg), 10.4.19 (opt), 10.5.10 (dbg), 10.5.10 (opt), 10.6.1 (dbg), 10.6.1 (opt)

            Bug (or feature/syntax) confirmed not present in:
            MariaDB: 10.2.38 (dbg), 10.2.38 (opt), 10.3.29 (dbg), 10.3.29 (opt)
            MySQL: 5.5.62 (dbg), 5.5.62 (opt), 5.6.51 (dbg), 5.6.51 (opt), 5.7.34 (dbg), 5.7.34 (opt), 8.0.24 (dbg), 8.0.24 (opt)

            Roel Roel Van de Paar added a comment - - edited Found yet another stack. Testcase looks to be non-sporadic. SET join_cache_level=8; CREATE TEMPORARY TABLE t AS SELECT * FROM mysql. user ; CREATE TEMPORARY TABLE t2 LIKE t; SELECT t.*,t2.* FROM t NATURAL JOIN t2; Leads to: 10.6.1 f8665314d4ba190679001b81bb7d9fd7a38fc0f6 (Debug) Core was generated by `/test/MD100521-mariadb-10.6.1-linux-x86_64-dbg/bin/mysqld --no-defaults --core-'. Program terminated with signal SIGSEGV, Segmentation fault. #0 restore_prev_nj_state (last=last@entry=0x1000100010001) at /test/10.6_dbg/sql/sql_select.cc:17096 17096 TABLE_LIST *last_emb= last->table->pos_in_table_list->embedding; [Current thread is 1 (Thread 0x152900565700 (LWP 3239121))] (gdb) bt #0 restore_prev_nj_state (last=last@entry=0x1000100010001) at /test/10.6_dbg/sql/sql_select.cc:17096 #1 0x0000558ff34356e9 in best_extension_by_limited_search (join=join@entry=0x1528c40166c8, remaining_tables=remaining_tables@entry=1, idx=idx@entry=1, record_count=record_count@entry=1, read_time=1.2, search_depth=search_depth@entry=61, prune_level=prune_level@entry=1, use_cond_selectivity=use_cond_selectivity@entry=4) at /test/10.6_dbg/sql/sql_select.cc:9880 #2 0x0000558ff343557c in best_extension_by_limited_search (join=join@entry=0x1528c40166c8, remaining_tables=remaining_tables@entry=3, idx=idx@entry=0, record_count=record_count@entry=1, read_time=read_time@entry=0, search_depth=search_depth@entry=62, prune_level=prune_level@entry=1, use_cond_selectivity=use_cond_selectivity@entry=4) at /test/10.6_dbg/sql/sql_select.cc:9837 #3 0x0000558ff343683b in greedy_search (use_cond_selectivity=<optimized out>, prune_level=<optimized out>, search_depth=62, remaining_tables=3, join=0x1528c40166c8) at /test/10.6_dbg/sql/sql_select.cc:8954 #4 choose_plan (join=join@entry=0x1528c40166c8, join_tables=<optimized out>) at /test/10.6_dbg/sql/sql_select.cc:8519 #5 0x0000558ff346613b in make_join_statistics (join=join@entry=0x1528c40166c8, tables_list=@0x1528c40142d0: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x1528c4016c68, last = 0x1528c4016c78, elements = 2}, <No data fields>}, keyuse_array=keyuse_array@entry=0x1528c40169e0) at /test/10.6_dbg/sql/sql_select.cc:5758 #6 0x0000558ff346d295 in JOIN::optimize_inner (this=this@entry=0x1528c40166c8) at /test/10.6_dbg/sql/sql_select.cc:2336 #7 0x0000558ff346d560 in JOIN::optimize (this=this@entry=0x1528c40166c8) at /test/10.6_dbg/sql/sql_select.cc:1705 #8 0x0000558ff346df29 in mysql_select (thd=thd@entry=0x1528c4000db8, tables=0x1528c4014808, fields=@0x1528c40141e0: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x1528c4014668, last = 0x1528c40a0b88, elements = 94}, <No data fields>}, conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x1528c40166a0, unit=0x1528c4005120, select_lex=0x1528c4014088) at /test/10.6_dbg/sql/sql_select.cc:4851 #9 0x0000558ff346e23e in handle_select (thd=thd@entry=0x1528c4000db8, lex=lex@entry=0x1528c4005058, result=result@entry=0x1528c40166a0, setup_tables_done_option=setup_tables_done_option@entry=0) at /test/10.6_dbg/sql/sql_select.cc:446 #10 0x0000558ff33e0eff in execute_sqlcom_select (thd=thd@entry=0x1528c4000db8, all_tables=0x1528c4014808) at /test/10.6_dbg/sql/sql_parse.cc:6244 #11 0x0000558ff33eddf8 in mysql_execute_command (thd=thd@entry=0x1528c4000db8) at /test/10.6_dbg/sql/sql_parse.cc:3940 #12 0x0000558ff33da02b in mysql_parse (thd=thd@entry=0x1528c4000db8, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x152900564410) at /test/10.6_dbg/sql/sql_parse.cc:8018 #13 0x0000558ff33e8e5d in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x1528c4000db8, packet=packet@entry=0x1528c400b799 "SELECT t.*,t2.* FROM t NATURAL JOIN t2", packet_length=packet_length@entry=38, blocking=blocking@entry=true) at /test/10.6_dbg/sql/sql_class.h:1333 #14 0x0000558ff33ec250 in do_command (thd=0x1528c4000db8, blocking=blocking@entry=true) at /test/10.6_dbg/sql/sql_parse.cc:1406 #15 0x0000558ff3546dec in do_handle_one_connection (connect=<optimized out>, connect@entry=0x558ff5a61028, put_in_cache=put_in_cache@entry=true) at /test/10.6_dbg/sql/sql_connect.cc:1410 #16 0x0000558ff35473f1 in handle_one_connection (arg=arg@entry=0x558ff5a61028) at /test/10.6_dbg/sql/sql_connect.cc:1312 #17 0x0000558ff39f9cee in pfs_spawn_thread (arg=0x558ff594a878) at /test/10.6_dbg/storage/perfschema/pfs.cc:2201 #18 0x00001529178e0609 in start_thread (arg=<optimized out>) at pthread_create.c:477 #19 0x00001529174cf293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95 Bug confirmed present in: MariaDB: 10.4.19 (dbg), 10.4.19 (opt), 10.5.10 (dbg), 10.5.10 (opt), 10.6.1 (dbg), 10.6.1 (opt) Bug (or feature/syntax) confirmed not present in: MariaDB: 10.2.38 (dbg), 10.2.38 (opt), 10.3.29 (dbg), 10.3.29 (opt) MySQL: 5.5.62 (dbg), 5.5.62 (opt), 5.6.51 (dbg), 5.6.51 (opt), 5.7.34 (dbg), 5.7.34 (opt), 8.0.24 (dbg), 8.0.24 (opt)

            Fixed by fix for MDEV-17783. Testcase added.

            psergei Sergei Petrunia added a comment - Fixed by fix for MDEV-17783 . Testcase added.

            People

              psergei Sergei Petrunia
              Roel Roel Van de Paar
              Votes:
              0 Vote for this issue
              Watchers:
              5 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.