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

SIGSEGV in THD::is_error | Item::save_in_field | Item_trigger_field::set_value

    XMLWordPrintable

Details

    • Not for Release Notes
    • Q3/2026 Server Maintenance

    Description

      CREATE TABLE t1(a INT, b INT);
      DELIMITER $$;
      CREATE FUNCTION f() RETURNS INT
      BEGIN
        EXECUTE IMMEDIATE 'SELECT 1';
        RETURN 5;
      END$$
      CREATE TRIGGER tr BEFORE INSERT ON t1 FOR EACH ROW SET NEW.b = f()$$
      DELIMITER ;$$
      INSERT INTO t1(a) VALUES (1);
       
      #cleanup
      DROP TABLE t1; 
      DROP FUNCTION f;
      

      Leads to

      MDEV-39518 CS 13.1.0 ba0a2e08727bc136c1b25d527f9441389d22bf7b (Optimized, Clang 18.1.3-11) Build 30/06/2026

      Core was generated by `/test/mtest/MDEV-39518/MD300626-mariadb-13.1.0-linux-x86_64-opt/bin/mariadbd --'.
      Program terminated with signal SIGSEGV, Segmentation fault.
      #0  THD::is_error (this=0x0)at /test/mtest/MDEV-39518/bb-13.1-bar-MDEV-39518_opt/sql/sql_class.h:5249
       
      [Current thread is 1 (LWP 3121774)]
      (gdb) bt
      #0  THD::is_error (this=0x0)at /test/mtest/MDEV-39518/bb-13.1-bar-MDEV-39518_opt/sql/sql_class.h:5249
      #1  Item::save_in_field (this=0x681e5c029210, field=0x681e5c041190, no_conversions=false)at /test/mtest/MDEV-39518/bb-13.1-bar-MDEV-39518_opt/sql/item.cc:7361
      #2  0x00006363f92dfd73 in Item_trigger_field::set_value (this=0x681e5c029d00, thd=0x681e5c000c70, it=<optimized out>)at /test/mtest/MDEV-39518/bb-13.1-bar-MDEV-39518_opt/sql/item.cc:10778
      #3  0x00006363f91e8fd9 in Item_trigger_field::set_value (this=0x681e5c041190, thd=0x681e5c000c70, it=0x4)at /test/mtest/MDEV-39518/bb-13.1-bar-MDEV-39518_opt/sql/item.h:7798
      #4  sp_instr_set_trigger_field::exec_core (this=0x681e5c045600, thd=0x681e5c000c70, nextp=0x7041100f3484)at /test/mtest/MDEV-39518/bb-13.1-bar-MDEV-39518_opt/sql/sp_instr.cc:1716
      #5  0x00006363f91e6438 in sp_lex_keeper::reset_lex_and_exec_core (this=this@entry=0x681e5c045638, thd=thd@entry=0x681e5c000c70, nextp=nextp@entry=0x7041100f3484, open_tables=true, instr=instr@entry=0x681e5c045600, rerun_the_same_instr=<optimized out>)at /test/mtest/MDEV-39518/bb-13.1-bar-MDEV-39518_opt/sql/sp_instr.cc:420
      #6  0x00006363f91e6a36 in sp_lex_keeper::validate_lex_and_exec_core (this=0x681e5c045638, thd=0x681e5c000c70, nextp=0x7041100f3484, open_tables=<optimized out>, instr=0x681e5c045600)at /test/mtest/MDEV-39518/bb-13.1-bar-MDEV-39518_opt/sql/sp_instr.cc:599
      #7  0x00006363f8f9b8aa in sp_head::execute (this=this@entry=0x681e5c027ec0, thd=thd@entry=0x681e5c000c70, merge_da_on_success=false)at /test/mtest/MDEV-39518/bb-13.1-bar-MDEV-39518_opt/sql/sp_head.cc:1292
      #8  0x00006363f8f9c907 in sp_head::execute_trigger (this=0x681e5c027ec0, thd=0x681e5c000c70, db_name=<optimized out>, table_name=<optimized out>, grant_info=<optimized out>)at /test/mtest/MDEV-39518/bb-13.1-bar-MDEV-39518_opt/sql/sp_head.cc:1805
      #9  0x00006363f910b6a6 in Table_triggers_list::process_triggers (this=0x681e5c041450, thd=0x681e5c000c70, event=TRG_EVENT_INSERT, time_type=<optimized out>, old_row_is_record1=<optimized out>, skip_row_indicator=0x7041100f3e48, fields_in_update_stmt=0x681e5c0061a0)at /test/mtest/MDEV-39518/bb-13.1-bar-MDEV-39518_opt/sql/sql_trigger.cc:2847
      #10 0x00006363f8fd70a1 in fill_record_n_invoke_before_triggers (thd=thd@entry=0x681e5c000c70, table=table@entry=0x681e5c022390, fields=@0x681e5c0061a0: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x681e5c018530, last = 0x681e5c018530, elements = 1}, <No data fields>}, values=@0x681e5c018a40: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x681e5c018b00, last = 0x681e5c018b00, elements = 1}, <No data fields>}, ignore_errors=<optimized out>, event=event@entry=TRG_EVENT_INSERT, skip_row_indicator=0x7041100f3e48)at /test/mtest/MDEV-39518/bb-13.1-bar-MDEV-39518_opt/sql/sql_base.cc:9527
      #11 0x00006363f9005a9a in mysql_insert (thd=thd@entry=0x681e5c000c70, table_list=0x681e5c017ca0, fields=@0x681e5c0061a0: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x681e5c018530, last = 0x681e5c018530, elements = 1}, <No data fields>}, values_list=@0x681e5c0061e8: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x681e5c018b10, last = 0x681e5c018b10, elements = 1}, <No data fields>}, update_fields=@0x681e5c0061d0: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x6363fa3013a8 <end_of_list>, last = 0x681e5c0061d0, elements = 0}, <No data fields>}, update_values=@0x681e5c0061b8: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x6363fa3013a8 <end_of_list>, last = 0x681e5c0061b8, elements = 0}, <No data fields>}, duplic=DUP_ERROR, ignore=<optimized out>, result=0x0)at /test/mtest/MDEV-39518/bb-13.1-bar-MDEV-39518_opt/sql/sql_insert.cc:1145
      #12 0x00006363f9045ba6 in mysql_execute_command (thd=thd@entry=0x681e5c000c70, is_called_from_prepared_stmt=false)at /test/mtest/MDEV-39518/bb-13.1-bar-MDEV-39518_opt/sql/sql_parse.cc:4502
      #13 0x00006363f903e5c2 in mysql_parse (thd=thd@entry=0x681e5c000c70, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x7041100f44d0)at /test/mtest/MDEV-39518/bb-13.1-bar-MDEV-39518_opt/sql/sql_parse.cc:7945
      #14 0x00006363f903cb03 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x681e5c000c70, packet=packet@entry=0x681e5c008dc1 "INSERT INTO t1(a) VALUES (1)", packet_length=packet_length@entry=28, blocking=true)at /test/mtest/MDEV-39518/bb-13.1-bar-MDEV-39518_opt/sql/sql_parse.cc:1903
      #15 0x00006363f903ea41 in do_command (thd=thd@entry=0x681e5c000c70, blocking=true)at /test/mtest/MDEV-39518/bb-13.1-bar-MDEV-39518_opt/sql/sql_parse.cc:1437
      #16 0x00006363f916771d in do_handle_one_connection (connect=<optimized out>, connect@entry=0x636439804300, put_in_cache=true)at /test/mtest/MDEV-39518/bb-13.1-bar-MDEV-39518_opt/sql/sql_connect.cc:1503
      #17 0x00006363f9167552 in handle_one_connection (arg=arg@entry=0x636439804300)at /test/mtest/MDEV-39518/bb-13.1-bar-MDEV-39518_opt/sql/sql_connect.cc:1415
      #18 0x00006363f9507aa3 in pfs_spawn_thread (arg=0x636439823590)at /test/mtest/MDEV-39518/bb-13.1-bar-MDEV-39518_opt/storage/perfschema/pfs.cc:2198
      #19 0x000070411109caa4 in start_thread (arg=<optimized out>)at ./nptl/pthread_create.c:447
      #20 0x0000704111129c6c in clone3 ()at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
      

      Attachments

        Issue Links

          Activity

            People

              bar Alexander Barkov
              ramesh Ramesh Sivaraman
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - 4.7h Original Estimate - 4.7h
                  4.7h
                  Remaining:
                  Remaining Estimate - 0d
                  0d
                  Logged:
                  Time Spent - 6.5h
                  6.5h

                  Git Integration

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