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

Assertion `select_lex->leaf_tables_saved' failed in bool setup_tables(THD *, Name_resolution_context *, List<TABLE_LIST> *, TABLE_LIST *, List<TABLE_LIST> &, bool, bool)

    XMLWordPrintable

Details

    • Can result in hang or crash

    Description

      PREPARE s FROM "CREATE TABLE p AS SELECT 1 WHERE ''&& 0";
      CREATE TABLE t1 (id INT);
      SET sql_mode=DEFAULT;
      --ERROR ER_TRUNCATED_WRONG_VALUE
      EXECUTE s;
      LOCK TABLE t1 READ;
      --ERROR ER_TABLE_NOT_LOCKED
      EXECUTE s;
      START TRANSACTION;
      EXECUTE s;
      

      Leads to:

      CS 13.0.0 d755574c47f101917aee29ea847e214c24c92c0b (Debug, Clang 18.1.3-11) Build 27/02/2026

      mariadbd: /test/12.3_dbg/sql/sql_base.cc:8472: bool setup_tables(THD *, Name_resolution_context *, List<TABLE_LIST> *, TABLE_LIST *, List<TABLE_LIST> &, bool, bool): Assertion `select_lex->leaf_tables_saved' failed.
      

      CS 13.0.0 d755574c47f101917aee29ea847e214c24c92c0b (Debug, Clang 18.1.3-11) Build 27/02/2026

      Core was generated by `/test/MD270226-mariadb-13.0.0-linux-x86_64-dbg/bin/mariadbd --no-defaults --max'.
      Program terminated with signal SIGABRT, Aborted.
      Download failed: Invalid argument.  Continuing without source file ./nptl/./nptl/pthread_kill.c.
      #0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=<optimized out>)at ./nptl/pthread_kill.c:44
       
      [Current thread is 1 (LWP 2682194)]
      (gdb) bt
      #0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=<optimized out>)at ./nptl/pthread_kill.c:44
      #1  __pthread_kill_internal (signo=6, threadid=<optimized out>)at ./nptl/pthread_kill.c:78
      #2  __GI___pthread_kill (threadid=<optimized out>, signo=signo@entry=6)at ./nptl/pthread_kill.c:89
      #3  0x00007ec61ae4527e in __GI_raise (sig=sig@entry=6)at ../sysdeps/posix/raise.c:26
      #4  0x00007ec61ae288ff in __GI_abort () at ./stdlib/abort.c:79
      #5  0x00007ec61ae2881b in __assert_fail_base (fmt=0x7ec61afd01e8 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x5b4af03505b1 "select_lex->leaf_tables_saved", file=file@entry=0x5b4af034ec12 "/test/12.3_dbg/sql/sql_base.cc", line=line@entry=8472, function=function@entry=0x5b4af035053b "bool setup_tables(THD *, Name_resolution_context *, List<TABLE_LIST> *, TABLE_LIST *, List<TABLE_LIST> &, bool, bool)") at ./assert/assert.c:96
      #6  0x00007ec61ae3b517 in __assert_fail (assertion=0x5b4af03505b1 "select_lex->leaf_tables_saved", file=0x5b4af034ec12 "/test/12.3_dbg/sql/sql_base.cc", line=8472, function=0x5b4af035053b "bool setup_tables(THD *, Name_resolution_context *, List<TABLE_LIST> *, TABLE_LIST *, List<TABLE_LIST> &, bool, bool)")at ./assert/assert.c:105
      #7  0x00005b4aef183441 in setup_tables (thd=0x7ec4b8000d58, context=0x7ec4b8026950, from_clause=0x7ec4b8026ac0, tables=0x0, leaves=@0x7ec4b8026b20: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x5b4af1015010 <end_of_list>, last = 0x7ec4b8026b20, elements = 0}, <No data fields>}, select_insert=false, full_table_list=false)at /test/12.3_dbg/sql/sql_base.cc:8472
      #8  0x00005b4aef183bcb in setup_tables_and_check_access (thd=0x7ec4b8000d58, context=0x7ec4b8026950, from_clause=0x7ec4b8026ac0, tables=0x0, leaves=@0x7ec4b8026b20: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x5b4af1015010 <end_of_list>, last = 0x7ec4b8026b20, elements = 0}, <No data fields>}, select_insert=false, want_access_first=SELECT_ACL, want_access=SELECT_ACL, full_table_list=false)at /test/12.3_dbg/sql/sql_base.cc:8576
      #9  0x00005b4aef2b1c83 in JOIN::prepare (this=0x7ec4b801a618, tables_init=0x0, conds_init=0x7ec4b801a198, og_num=0, order_init=0x0, skip_order_by=false, group_init=0x0, having_init=0x0, proc_param_init=0x0, select_lex_arg=0x7ec4b8026908, unit_arg=0x7ec4b8024208)at /test/12.3_dbg/sql/sql_select.cc:1483
      #10 0x00005b4aef2adc69 in mysql_select (thd=0x7ec4b8000d58, tables=0x0, fields=@0x7ec4b8026bc0: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x7ec4b8026e68, last = 0x7ec4b8026e68, elements = 1}, <No data fields>}, conds=0x7ec4b801a198, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2201187781376, result=0x7ec4b801a4d0, unit=0x7ec4b8024208, select_lex=0x7ec4b8026908)at /test/12.3_dbg/sql/sql_select.cc:5410
      #11 0x00005b4aef2ad865 in handle_select (thd=0x7ec4b8000d58, lex=0x7ec4b8024128, result=0x7ec4b801a4d0, setup_tables_done_option=0)at /test/12.3_dbg/sql/sql_select.cc:636
      #12 0x00005b4aef383ba8 in Sql_cmd_create_table_like::execute (this=0x7ec4b8026138, thd=0x7ec4b8000d58)at /test/12.3_dbg/sql/sql_table.cc:13788
      #13 0x00005b4aef24e322 in mysql_execute_command (thd=0x7ec4b8000d58, is_called_from_prepared_stmt=true) at /test/12.3_dbg/sql/sql_parse.cc:5898
      #14 0x00005b4aef28baef in Prepared_statement::execute (this=0x7ec4b80194b8, expanded_query=0x7ec5f484f220, open_cursor=false, result_arg=0x7ec4b8019608, cursor_arg=0x7ec4b8019678)at /test/12.3_dbg/sql/sql_prepare.cc:5344
      #15 0x00005b4aef28b18b in Prepared_statement::execute_loop (this=0x7ec4b80194b8, expanded_query=0x7ec5f484f220, open_cursor=false, result_arg=0x7ec4b8019608, cursor_arg=0x7ec4b8019678, instrs_set_placeholder=@0x7ec5f484f1ac: {<Slice<unsigned int>> = {m_offset = 0, m_count = 0}, <No data fields>}, packet=0x0, packet_end=0x0)at /test/12.3_dbg/sql/sql_prepare.cc:4703
      #16 0x00005b4aef287529 in mysql_sql_stmt_execute (thd=0x7ec4b8000d58, name=@0x7ec4b8006e18: {<Lex_ident_sys_st> = {<st_mysql_const_lex_string> = {str = 0x7ec4b801a190 "s", length = 1}, <Sql_alloc> = {<No data fields>}, <No data fields>}, <No data fields>}, cmd=0x5b4af0366e84 "EXECUTE", open_dynamic_cursor=false, result_arg=0x0, cursor_arg=0x0)at /test/12.3_dbg/sql/sql_prepare.cc:3635
      #17 0x00005b4aef287195 in mysql_sql_stmt_execute (thd=0x7ec4b8000d58)at /test/12.3_dbg/sql/sql_prepare.cc:3649
      #18 0x00005b4aef245415 in mysql_execute_command (thd=0x7ec4b8000d58, is_called_from_prepared_stmt=false) at /test/12.3_dbg/sql/sql_parse.cc:4003
      #19 0x00005b4aef23d5b4 in mysql_parse (thd=0x7ec4b8000d58, rawbuf=0x7ec4b801a120 "EXECUTE s", length=9, parser_state=0x7ec5f4850ab0)at /test/12.3_dbg/sql/sql_parse.cc:7937
      #20 0x00005b4aef23a95d in dispatch_command (command=COM_QUERY, thd=0x7ec4b8000d58, packet=0x7ec4b800b4c9 "EXECUTE s", packet_length=9, blocking=true) at /test/12.3_dbg/sql/sql_parse.cc:1896
      #21 0x00005b4aef23e163 in do_command (thd=0x7ec4b8000d58, blocking=true)at /test/12.3_dbg/sql/sql_parse.cc:1432
      #22 0x00005b4aef438999 in do_handle_one_connection (connect=0x5b4af4f60258, put_in_cache=true) at /test/12.3_dbg/sql/sql_connect.cc:1503
      #23 0x00005b4aef43873e in handle_one_connection (arg=0x5b4af4e77c88)at /test/12.3_dbg/sql/sql_connect.cc:1415
      #24 0x00007ec61ae9caa4 in start_thread (arg=<optimized out>)at ./nptl/pthread_create.c:447
      #25 0x00007ec61af29c6c in clone3 ()at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
      

      Bug Detection Matrix

          Rel    o/d  Build   Commit                                    UniqueID observed
      CS  10.6   dbg  190226  8882f8fe6c5a87e2b367e260627af88ce9130d44  No bug found
      CS  10.6   opt  190226  8882f8fe6c5a87e2b367e260627af88ce9130d44  No bug found
      CS  10.11  dbg  130326  ed78f526006fa3a86863c0ea16f27bfa39cd6657  No bug found
      CS  10.11  opt  130326  ed78f526006fa3a86863c0ea16f27bfa39cd6657  No bug found
      CS  11.4   dbg  270226  a6e98760d9ded7803a752b9fb0a4b31ba6fb4c11  No bug found
      CS  11.4   opt  270226  a6e98760d9ded7803a752b9fb0a4b31ba6fb4c11  No bug found
      CS  11.8   dbg  190226  65ee9a7b4694d1b6f366b5a7a3d1b0549e5a3671  select_lex->leaf_tables_saved|SIGABRT|setup_tables|setup_tables_and_check_access|JOIN::prepare|mysql_select
      CS  11.8   opt  190226  65ee9a7b4694d1b6f366b5a7a3d1b0549e5a3671  No bug found
      CS  12.2   dbg  190226  d26a6f44c1f2119377e79a9540886c6d8c01472f  select_lex->leaf_tables_saved|SIGABRT|setup_tables|setup_tables_and_check_access|JOIN::prepare|mysql_select
      CS  12.2   opt  190226  d26a6f44c1f2119377e79a9540886c6d8c01472f  No bug found
      CS  12.3   dbg  190226  21a0714a118614982d20bfa504763d7247800091  select_lex->leaf_tables_saved|SIGABRT|setup_tables|setup_tables_and_check_access|JOIN::prepare|mysql_select
      CS  12.3   opt  190226  21a0714a118614982d20bfa504763d7247800091  No bug found
      CS  13.0   dbg  060326  ef4be39bfcbae1b0090a3098e511d14457d6139f  select_lex->leaf_tables_saved|SIGABRT|setup_tables|setup_tables_and_check_access|JOIN::prepare|mysql_select
      CS  13.0   opt  060326  ef4be39bfcbae1b0090a3098e511d14457d6139f  No bug found
      ES  10.6   dbg  151225  bc33b05c6a65de27dbe811a30bc37c207d60ee8e  No bug found
      ES  10.6   opt  151225  bc33b05c6a65de27dbe811a30bc37c207d60ee8e  No bug found
      ES  11.4   dbg  151225  714f2134597e00f4ff107886cf3a55eff48e4510  No bug found
      ES  11.4   opt  151225  714f2134597e00f4ff107886cf3a55eff48e4510  No bug found
      ES  11.8   dbg  151225  4008de1a5b06105a64821db7b851328f1b27d99e  select_lex->leaf_tables_saved|SIGABRT|setup_tables|setup_tables_and_check_access|JOIN::prepare|mysql_select
      ES  11.8   opt  151225  4008de1a5b06105a64821db7b851328f1b27d99e  No bug found
      

      Attachments

        Activity

          People

            shulga Dmitry Shulga
            ramesh Ramesh Sivaraman
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Git Integration

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