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

Server crashes in THD::get_variable / Item_func_xml_method_getNumberVal::val_real when trigger runs in another connection

    XMLWordPrintable

Details

    Description

      XMLTYPE method items keep the THD of the connection that parsed the trigger. The trigger body lives in the shared TABLE, so when another connection fires it, m_thd->spcont is the parsing connection's (NULL when idle).

      CREATE TABLE t1 (a DOUBLE);
      --delimiter $$
      CREATE TRIGGER tr BEFORE INSERT ON t1 FOR EACH ROW
      BEGIN
        DECLARE x XMLTYPE DEFAULT '<a>42</a>';
        SET NEW.a= x.getNumberVal();
      END$$
      --delimiter ;
      connect (c1,localhost,root,,test);
      INSERT INTO t1 VALUES (1);
      connection default;
      INSERT INTO t1 VALUES (2);
      SELECT * FROM t1;
      disconnect c1;
      DROP TABLE t1;

      13.2.0-MariaDB-asan-debug-log source revision: 5370405937a659351b9203337e76e4597cfb6eb0
      #0  __pthread_kill_implementation (no_tid=0, signo=11, threadid=<optimized out>) at ./nptl/pthread_kill.c:44
      #1  __pthread_kill_internal (signo=11, threadid=<optimized out>) at ./nptl/pthread_kill.c:78
      #2  __GI___pthread_kill (threadid=<optimized out>, signo=11) at ./nptl/pthread_kill.c:89
      #3  0x00005d713ac9e9f5 in my_write_core (sig=11) at /13.2/src/mysys/stacktrace.c:424
      #4  0x00005d7138d7348e in handle_fatal_signal (sig=11) at /13.2/src/sql/signal_handler.cc:300
      #5  <signal handler called>
      #6  0x00005d7138e4cfb4 in Bounds_checked_array<Item_field*>::operator[] (this=0x28, n=0) at /13.2/src/sql/sql_array.h:71
      #7  0x00005d71395578f2 in sp_rcontext::get_variable (var_idx=<optimized out>, this=<optimized out>) at /13.2/src/sql/sp_rcontext.h:234
      #8  THD::get_variable (this=<optimized out>, addr=...) at /13.2/src/sql/sql_class.cc:4775
      #9  0x00005d713ae7f5df in Item_func_xml_method_getNumberVal::val_real (this=0x5250001faab0) at /13.2/src/plugin/type_xmltype/sql_type_xmltype.cc:1062
      #10 0x00005d7138e11a16 in Item::save_real_in_field (this=0x5250001faab0, field=0x5250001f7250, no_conversions=false) at /13.2/src/sql/item.cc:7542
      #11 0x00005d7139e45730 in Type_handler_real_result::Item_save_in_field (this=<optimized out>, item=<optimized out>, field=<optimized out>, no_conversions=<optimized out>) at /13.2/src/sql/sql_type.cc:4498
      #12 0x00005d7138dd17a7 in Item::save_in_field (this=0x5250001faab0, field=0x5250001f7250, no_conversions=false) at /13.2/src/sql/item.cc:7582
      #13 0x00005d7138deb8cb in Item_trigger_field::set_value (this=0x5250001fac18, thd=0x52c000080220, it=0x5250001fae48) at /13.2/src/sql/item.cc:10956
      #14 0x00005d7139e19616 in Item_trigger_field::set_value (it=0x5250001fae48, thd=0x52c000080220, this=<optimized out>) at /13.2/src/sql/item.h:7935
      #15 sp_instr_set_trigger_field::exec_core (this=0x5250001fad90, thd=0x52c000080220, nextp=0x745466b73030) at /13.2/src/sql/sp_instr.cc:1741
      #16 0x00005d7139e23cdf in sp_lex_keeper::reset_lex_and_exec_core (this=this@entry=0x5250001fadd0, thd=thd@entry=0x52c000080220, nextp=nextp@entry=0x745466b73030, open_tables=open_tables@entry=true, instr=instr@entry=0x5250001fad90, rerun_the_same_instr=rerun_the_same_instr@entry=false) at /13.2/src/sql/sp_instr.cc:420
      #17 0x00005d7139e2a434 in sp_lex_keeper::validate_lex_and_exec_core (this=this@entry=0x5250001fadd0, thd=thd@entry=0x52c000080220, nextp=nextp@entry=0x745466b73030, open_tables=open_tables@entry=true, instr=instr@entry=0x5250001fad90) at /13.2/src/sql/sp_instr.cc:624
      #18 0x00005d7139e2c7b4 in sp_instr_set_trigger_field::execute (this=0x5250001fad90, thd=0x52c000080220, nextp=<optimized out>) at /13.2/src/sql/sp_instr.cc:1733
      #19 0x00005d71393d60d2 in sp_head::execute (this=this@entry=0x5250001f9148, thd=thd@entry=0x52c000080220, merge_da_on_success=merge_da_on_success@entry=false) at /13.2/src/sql/sp_head.cc:1346
      #20 0x00005d71393d848d in sp_head::execute_trigger (this=0x5250001f9148, thd=thd@entry=0x52c000080220, db_name=<optimized out>, table_name=<optimized out>, grant_info=grant_info@entry=0x5250001f7c08) at /13.2/src/sql/sp_head.cc:1862
      #21 0x00005d71399ec8a2 in Table_triggers_list::process_triggers (this=this@entry=0x5250001f7578, thd=thd@entry=0x52c000080220, event=event@entry=TRG_EVENT_INSERT, time_type=time_type@entry=TRG_ACTION_BEFORE, old_row_is_record1=old_row_is_record1@entry=true, skip_row_indicator=skip_row_indicator@entry=0x745466b72830, fields_in_update_stmt=<optimized out>) at /13.2/src/sql/sql_trigger.cc:2879
      #22 0x00005d71394d867e in fill_record_n_invoke_before_triggers (thd=thd@entry=0x52c000080220, table=table@entry=0x519000060ea0, ptr=0x5250001f7210, values=..., ignore_errors=ignore_errors@entry=false, event=event@entry=TRG_EVENT_INSERT, skip_row_indicator=0x745466b72830) at /13.2/src/sql/sql_base.cc:9946
      #23 0x00005d71395f9dc2 in mysql_insert (thd=thd@entry=0x52c000080220, table_list=0x52d0000f0580, fields=..., values_list=..., update_fields=..., update_values=..., duplic=<optimized out>, ignore=<optimized out>, result=<optimized out>) at /13.2/src/sql/sql_insert.cc:1193
      #24 0x00005d71396d23ac in mysql_execute_command (thd=thd@entry=0x52c000080220, is_called_from_prepared_stmt=is_called_from_prepared_stmt@entry=false) at /13.2/src/sql/sql_parse.cc:4549
      #25 0x00005d71396dcfe5 in mysql_parse (thd=thd@entry=0x52c000080220, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x745466de11b0) at /13.2/src/sql/sql_parse.cc:8005
      #26 0x00005d71396e0c99 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x52c000080220, packet=packet@entry=0x52900028f221 "INSERT INTO t1 VALUES (2)", packet_length=packet_length@entry=25, blocking=blocking@entry=true) at /13.2/src/sql/sql_parse.cc:1903
      #27 0x00005d71396e54fb in do_command (thd=thd@entry=0x52c000080220, blocking=blocking@entry=true) at /13.2/src/sql/sql_parse.cc:1437
      #28 0x00005d7139bd7437 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x50b000004730, put_in_cache=put_in_cache@entry=true) at /13.2/src/sql/sql_connect.cc:1514
      #29 0x00005d7139bd783d in handle_one_connection (arg=arg@entry=0x50b000004730) at /13.2/src/sql/sql_connect.cc:1426
      #30 0x0000745473a5ea42 in asan_thread_start (arg=0x74547030f000) at ../../../../src/libsanitizer/asan/asan_interceptors.cpp:234
      #31 0x0000745472c9cb64 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:447
      #32 0x0000745472d29e8c in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78

      Attachments

        Issue Links

          Activity

            People

              holyfoot Alexey Botchkov
              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.