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

Assertion `thd->stmt_arena->is_stmt_prepare_or_first_stmt_execute() || thd->stmt_arena->is_conventional()' failed in Item_exists_subselect::exists2in_processor after 2nd execution of sp with cursor

    XMLWordPrintable

Details

    • Can result in hang or crash

    Description

      CREATE TABLE t1 (a INT);
      CREATE TABLE t2 (a INT);
      INSERT INTO t1 VALUES (1);
      INSERT INTO t2 VALUES (1);
       
      DELIMITER //;
      CREATE PROCEDURE p()
      BEGIN
        DECLARE done INT DEFAULT 0;
        DECLARE va INT;
        DECLARE c CURSOR FOR
          SELECT t1.a FROM t1
          WHERE EXISTS (SELECT 0 FROM t2 WHERE t1.a = t2.a);
        DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
        OPEN c;
        l: LOOP
          FETCH c INTO va;
          IF done THEN LEAVE l; END IF;
        END LOOP;
        CLOSE c;
      END//
      DELIMITER ;//
       
      CALL p();
      ALTER TABLE t2 ADD COLUMN extra INT;
       
      CALL p();
       
      DROP PROCEDURE p;
      DROP TABLE t1, t2;
      

      mariadbd: /11.4/src/sql/item_subselect.cc:3340: virtual bool Item_exists_subselect::exists2in_processor(void*): Assertion `thd->stmt_arena->is_stmt_prepare_or_first_stmt_execute() || thd->stmt_arena->is_conventional()' failed.
      260429 15:18:54 [ERROR] /11.4/bld/sql/mariadbd got signal 6 ;
       
      Server version: 11.4.11-MariaDB-asan-debug-log source revision: e43e0bad5b37cd79c5dfd8078ae9c16ace07095b
       
      posix/raise.c:27(__GI_raise)[0x7a0d1824527e]
      stdlib/abort.c:81(__GI_abort)[0x7a0d182288ff]
      intl/loadmsgcat.c:1177(_nl_load_domain)[0x7a0d1822881b]
      /lib/x86_64-linux-gnu/libc.so.6(+0x3b517)[0x7a0d1823b517]
      sql/item_subselect.cc:3342(Item_exists_subselect::exists2in_processor(void*))[0x5ec9bd36fa88]
      sql/item_subselect.cc:732(Item_subselect::walk(bool (Item::*)(void*), bool, void*))[0x5ec9bd348ec3]
      sql/item_cmpfunc.cc:1539(Item_in_optimizer::walk(bool (Item::*)(void*), bool, void*))[0x5ec9bd198616]
      sql/sql_select.cc:2273(JOIN::optimize_inner())[0x5ec9bca231bd]
      sql/sql_select.cc:2016(JOIN::optimize())[0x5ec9bca27d7c]
      sql/sql_select.cc:5402(mysql_select(THD*, TABLE_LIST*, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*))[0x5ec9bca28673]
      sql/sql_select.cc:643(handle_select(THD*, LEX*, select_result*, unsigned long long))[0x5ec9bca28e80]
      sql/sql_parse.cc:6224(execute_sqlcom_select(THD*, TABLE_LIST*))[0x5ec9bc8823b4]
      sql/sql_parse.cc:4012(mysql_execute_command(THD*, bool))[0x5ec9bc8a0a78]
      sql/sql_cursor.cc:72(mysql_open_cursor(THD*, select_result*, Server_side_cursor**))[0x5ec9bc79ddce]
      sql/sp_rcontext.cc:764(sp_cursor::open(THD*))[0x5ec9bc69e09a]
      sql/sp_instr.cc:1846(sp_instr_cpush::exec_core(THD*, unsigned int*))[0x5ec9bce999e8]
      sql/sp_instr.cc:333(sp_lex_keeper::reset_lex_and_exec_core(THD*, unsigned int*, bool, sp_instr*, bool))[0x5ec9bce97ca9]
      sql/sp_instr.cc:515(sp_lex_keeper::validate_lex_and_exec_core(THD*, unsigned int*, bool, sp_lex_instr*))[0x5ec9bce9c1cb]
      sql/sp_instr.cc:579(sp_lex_keeper::cursor_reset_lex_and_exec_core(THD*, unsigned int*, bool, sp_lex_instr*))[0x5ec9bce9c69e]
      sql/sp_instr.cc:1953(sp_instr_copen::execute(THD*, unsigned int*))[0x5ec9bce9c975]
      sql/sp_head.cc:1286(sp_head::execute(THD*, bool))[0x5ec9bc6892f9]
      sql/sp_head.cc:2305(sp_head::execute_procedure(THD*, List<Item>*))[0x5ec9bc68ccc0]
      sql/sql_parse.cc:3101(do_execute_sp(THD*, sp_head*))[0x5ec9bc880e34]
      sql/sql_parse.cc:3342(Sql_cmd_call::execute(THD*))[0x5ec9bc88bb0d]
      sql/sql_parse.cc:5916(mysql_execute_command(THD*, bool))[0x5ec9bc8ac052]
      sql/sql_parse.cc:7945(mysql_parse(THD*, char*, unsigned int, Parser_state*))[0x5ec9bc8adf3e]
      sql/sql_parse.cc:1925(dispatch_command(enum_server_command, THD*, char*, unsigned int, bool))[0x5ec9bc8b1e25]
      sql/sql_parse.cc:1433(do_command(THD*, bool))[0x5ec9bc8b69eb]
      sql/sql_connect.cc:1497(do_handle_one_connection(CONNECT*, bool))[0x5ec9bccc669e]
      sql/sql_connect.cc:1409(handle_one_connection)[0x5ec9bccc6b77]
      perfschema/pfs.cc:2204(pfs_spawn_thread)[0x5ec9bd770fbd]
      asan/asan_interceptors.cpp:234(asan_thread_start(void*))[0x7a0d1925ea42]
      nptl/pthread_create.c:447(start_thread)[0x7a0d1829caa4]
      x86_64/clone3.S:80(clone3)[0x7a0d18329c6c]
       
      Query (0x52d0000dc438): CALL p()
      
      

      No obvious immediate problem on a non-debug build.

      Attachments

        Issue Links

          Activity

            People

              shulga Dmitry Shulga
              alice Alice Sherepa
              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.