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

SIGSEGV and UBSAN invalid-enum-load in ha_mroonga::storage_create_foreign_key on INSERT

    XMLWordPrintable

Details

    • Not for Release Notes
    • Q4/2025 Server Development

    Description

      INSTALL SONAME 'ha_mroonga';
      CREATE GLOBAL TEMPORARY TABLE t (c INT) ENGINE=MRoonga ON COMMIT DELETE ROWS;
      --error ER_TABLE_EXISTS_ERROR
      CREATE TABLE t (d INT PRIMARY KEY);
      INSERT t VALUES (0);
      

      Leads to:

      MDEV-35915-8 CS 12.2.0 c7ea08421d34fa7d45e27919a869ade968bd88c4 (Optimized, Clang 21.1.3-20250923) Build 20/10/2025

      Core was generated by `/test/MDEV-35915_8_MD201025-mariadb-12.2.0-linux-x86_64-opt/bin/mariadbd --no-d'.
      Program terminated with signal SIGSEGV, Segmentation fault.
      #0  ha_mroonga::storage_create_foreign_key (this=this@entry=0x7865ed6f5b58, table=table@entry=0x786714b63ec0, grn_table_name=0x786714b60b20 "#sql-temptable-e2a23-4-0", field=field@entry=0x7865ed69acf0, table_obj=table_obj@entry=0x7865e44b2740, error=@0x786714b5daf4: 0)at /test/bb-12.2-nikita-global-tmp_opt/storage/mroonga/ha_mroonga.cpp:3640
       
      [Current thread is 1 (LWP 941106)]
      (gdb) bt
      #0  ha_mroonga::storage_create_foreign_key (this=this@entry=0x7865ed6f5b58, table=table@entry=0x786714b63ec0, grn_table_name=0x786714b60b20 "#sql-temptable-e2a23-4-0", field=field@entry=0x7865ed69acf0, table_obj=table_obj@entry=0x7865e44b2740, error=@0x786714b5daf4: 0)at /test/bb-12.2-nikita-global-tmp_opt/storage/mroonga/ha_mroonga.cpp:3640
      #1  0x00007866aab12ddd in ha_mroonga::storage_create (this=this@entry=0x7865ed6f5b58, name=name@entry=0x786714b65e20 "/test/MDEV-35915_8_MD201025-mariadb-12.2.0-linux-x86_64-opt/tmp/#sql-temptable-e2a23-4-0", table=table@entry=0x786714b63ec0, info=info@entry=0x786714b66090, tmp_share=tmp_share@entry=0x7865ed6f8b98)at /test/bb-12.2-nikita-global-tmp_opt/storage/mroonga/ha_mroonga.cpp:3539
      #2  0x00007866aab152f0 in ha_mroonga::create (this=0x7865ed6f5b58, name=0x786714b65e20 "/test/MDEV-35915_8_MD201025-mariadb-12.2.0-linux-x86_64-opt/tmp/#sql-temptable-e2a23-4-0", table=0x786714b63ec0, info=0x786714b66090)at /test/bb-12.2-nikita-global-tmp_opt/storage/mroonga/ha_mroonga.cpp:4240
      #3  0x00005d6aa2368780 in handler::ha_create (this=<optimized out>, name=name@entry=0x786714b65e20 "/test/MDEV-35915_8_MD201025-mariadb-12.2.0-linux-x86_64-opt/tmp/#sql-temptable-e2a23-4-0", form=form@entry=0x786714b63ec0, info_arg=info_arg@entry=0x786714b66090)at /test/bb-12.2-nikita-global-tmp_opt/sql/handler.cc:5974
      #4  0x00005d6aa2369cd9 in ha_create_table_from_share (thd=thd@entry=0x7865ec000c68, share=share@entry=0x786714b65048, create_info=create_info@entry=0x786714b66090, ref_length=ref_length@entry=0x786714b6433c)at /test/bb-12.2-nikita-global-tmp_opt/sql/handler.cc:6427
      #5  0x00005d6aa23695c5 in ha_create_table (thd=thd@entry=0x7865ec000c68, path=0x786714b65e20 "/test/MDEV-35915_8_MD201025-mariadb-12.2.0-linux-x86_64-opt/tmp/#sql-temptable-e2a23-4-0", db=0x7865ec017748 "test", table_name=0x7865ec017718 "t", create_info=0x786714b66090, frm=<optimized out>, skip_frm_file=<optimized out>)at /test/bb-12.2-nikita-global-tmp_opt/sql/handler.cc:6494
      #6  0x00005d6aa26f42f7 in create_table_impl (thd=thd@entry=0x7865ec000c68, ddl_log_state_create=ddl_log_state_create@entry=0x0, ddl_log_state_rm=<optimized out>, ddl_log_state_rm@entry=0x0, orig_db=@0x7865ec017770: {<Lex_ident_fs> = {<Lex_ident<Compare_table_names>> = {<Lex_cstring> = {<st_mysql_const_lex_string> = {str = 0x7865ec017748 "test", length = 4}, <No data fields>}, <No data fields>}, <No data fields>}, <No data fields>}, orig_table_name=@0x7865ec017780: {<Lex_ident_fs> = {<Lex_ident<Compare_table_names>> = {<Lex_cstring> = {<st_mysql_const_lex_string> = {str = 0x7865ec017718 "t", length = 1}, <No data fields>}, <No data fields>}, <No data fields>}, <No data fields>}, db=@0x7865ec017770: {<Lex_ident_fs> = {<Lex_ident<Compare_table_names>> = {<Lex_cstring> = {<st_mysql_const_lex_string> = {str = 0x7865ec017748 "test", length = 4}, <No data fields>}, <No data fields>}, <No data fields>}, <No data fields>}, table_name=@0x7865ec017780: {<Lex_ident_fs> = {<Lex_ident<Compare_table_names>> = {<Lex_cstring> = {<st_mysql_const_lex_string> = {str = 0x7865ec017718 "t", length = 1}, <No data fields>}, <No data fields>}, <No data fields>}, <No data fields>}, path=@0x786714b65dc0: {str = 0x786714b65e20 "/test/MDEV-35915_8_MD201025-mariadb-12.2.0-linux-x86_64-opt/tmp/#sql-temptable-e2a23-4-0", length = 88}, options={m_options = DDL_options_st::OPT_NONE}, create_info=0x786714b66090, alter_info=0x786714b66f60, create_table_mode=-2, is_trans=0x0, key_info=0x786714b65db8, key_count=0x786714b65dec, frm=0x786714b65dd0)at /test/bb-12.2-nikita-global-tmp_opt/sql/sql_table.cc:5017
      #7  0x00005d6aa26f3a34 in mysql_create_table_no_lock (thd=thd@entry=0x7865ec000c68, ddl_log_state_create=ddl_log_state_create@entry=0x0, ddl_log_state_rm=ddl_log_state_rm@entry=0x0, create_info=create_info@entry=0x786714b66090, alter_info=alter_info@entry=0x786714b66f60, is_trans=is_trans@entry=0x0, create_table_mode=-2, table_list=0x7865ec017758)at /test/bb-12.2-nikita-global-tmp_opt/sql/sql_table.cc:5119
      #8  0x00005d6aa26f55ab in open_global_temporary_table (thd=thd@entry=0x7865ec000c68, source=source@entry=0x7865ed69dbf0, out_table=out_table@entry=0x7865ec017758, mdl_ticket=mdl_ticket@entry=0x7865ec013790)at /test/bb-12.2-nikita-global-tmp_opt/sql/sql_table.cc:6311
      #9  0x00005d6aa2556314 in open_table (thd=thd@entry=0x7865ec000c68, table_list=table_list@entry=0x7865ec017758, ot_ctx=ot_ctx@entry=0x786714b677c8)at /test/bb-12.2-nikita-global-tmp_opt/sql/sql_base.cc:2351
      #10 0x00005d6aa2559048 in open_and_process_table (thd=0x7865ec000c68, tables=0x7865ec017758, counter=0x786714b67a7c, flags=0, prelocking_strategy=0x786714b67c40, ot_ctx=0x786714b677c8, has_prelocking_list=<optimized out>)at /test/bb-12.2-nikita-global-tmp_opt/sql/sql_base.cc:4308
      #11 open_tables (thd=thd@entry=0x7865ec000c68, options=@0x7865ec00666c: {m_options = DDL_options_st::OPT_NONE}, start=start@entry=0x786714b67a70, counter=counter@entry=0x786714b67a7c, flags=flags@entry=0, prelocking_strategy=prelocking_strategy@entry=0x786714b67c40)at /test/bb-12.2-nikita-global-tmp_opt/sql/sql_base.cc:4791
      #12 0x00005d6aa255aa14 in open_and_lock_tables (thd=0x7865ed6f5b58, thd@entry=0x7865ec000c68, options=@0x786714b63ec0: {m_options = (DDL_options_st::OPT_IF_EXISTS | unknown: 0x14b65008)}, tables=0x7865ec017758, derived=true, flags=3830130496, flags@entry=0, prelocking_strategy=0x786714b5daf4, prelocking_strategy@entry=0x786714b67c40)at /test/bb-12.2-nikita-global-tmp_opt/sql/sql_base.cc:5779
      #13 0x00005d6aa25e696f in open_and_lock_tables (thd=0x7865ec000c68, tables=0x7865ec017758, derived=true, flags=0)at /test/bb-12.2-nikita-global-tmp_opt/sql/sql_base.h:544
      #14 mysql_insert (thd=thd@entry=0x7865ec000c68, table_list=0x7865ec017758, fields=@0x7865ec006018: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x5d6aa2fe8ec0 <end_of_list>, last = 0x7865ec006018, elements = 0}, <No data fields>}, values_list=@0x7865ec006060: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x7865ec018420, last = 0x7865ec018420, elements = 1}, <No data fields>}, update_fields=@0x7865ec006048: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x5d6aa2fe8ec0 <end_of_list>, last = 0x7865ec006048, elements = 0}, <No data fields>}, update_values=@0x7865ec006030: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x5d6aa2fe8ec0 <end_of_list>, last = 0x7865ec006030, elements = 0}, <No data fields>}, duplic=DUP_ERROR, ignore=<optimized out>, result=0x0)at /test/bb-12.2-nikita-global-tmp_opt/sql/sql_insert.cc:789
      #15 0x00005d6aa262c924 in mysql_execute_command (thd=thd@entry=0x7865ec000c68, is_called_from_prepared_stmt=false)at /test/bb-12.2-nikita-global-tmp_opt/sql/sql_parse.cc:4460
      #16 0x00005d6aa26251d4 in mysql_parse (thd=thd@entry=0x7865ec000c68, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x786714b68420)at /test/bb-12.2-nikita-global-tmp_opt/sql/sql_parse.cc:7895
      #17 0x00005d6aa262397d in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x7865ec000c68, packet=packet@entry=0x7865ec0089f9 "INSERT t VALUES (0)", packet_length=packet_length@entry=19, blocking=true)at /test/bb-12.2-nikita-global-tmp_opt/sql/sql_parse.cc:1882
      #18 0x00005d6aa2625651 in do_command (thd=thd@entry=0x7865ec000c68, blocking=true) at /test/bb-12.2-nikita-global-tmp_opt/sql/sql_parse.cc:1421
      #19 0x00005d6aa277b74d in do_handle_one_connection (connect=<optimized out>, connect@entry=0x5d6aa5c17c78, put_in_cache=true)at /test/bb-12.2-nikita-global-tmp_opt/sql/sql_connect.cc:1414
      #20 0x00005d6aa277b50f in handle_one_connection (arg=arg@entry=0x5d6aa5c17c78)at /test/bb-12.2-nikita-global-tmp_opt/sql/sql_connect.cc:1326
      #21 0x00005d6aa2940349 in pfs_spawn_thread (arg=0x5d6aa5bc7978)at /test/bb-12.2-nikita-global-tmp_opt/storage/perfschema/pfs.cc:2198
      #22 0x0000786718c9ca94 in start_thread (arg=<optimized out>)at ./nptl/pthread_create.c:447
      #23 0x0000786718d29c3c in clone3 ()at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
      

      MDEV-35915-8 CS 12.2.0 c7ea08421d34fa7d45e27919a869ade968bd88c4 (Optimized, UBASAN, Clang 21.1.3-20250923) Build 20/10/2025

      /test/bb-12.2-nikita-global-tmp_opt_san/storage/mroonga/ha_mroonga.cpp:3640:14: runtime error: load of value 24528, which is not a valid value for type 'enum Keytype'
          #0 0x74026f1c9948 in ha_mroonga::storage_create_foreign_key(TABLE*, char const*, Field*, _grn_obj*, int&) /test/bb-12.2-nikita-global-tmp_opt_san/storage/mroonga/ha_mroonga.cpp:3640:14
          #1 0x74026f1c68a5 in ha_mroonga::storage_create(char const*, TABLE*, HA_CREATE_INFO*, st_mroonga_share*) /test/bb-12.2-nikita-global-tmp_opt_san/storage/mroonga/ha_mroonga.cpp:3539:9
          #2 0x74026f1d2f77 in ha_mroonga::create(char const*, TABLE*, HA_CREATE_INFO*) /test/bb-12.2-nikita-global-tmp_opt_san/storage/mroonga/ha_mroonga.cpp:4240:13
          #3 0x5fd06dc9ddd1 in handler::ha_create(char const*, TABLE*, HA_CREATE_INFO*) /test/bb-12.2-nikita-global-tmp_opt_san/sql/handler.cc:5974:14
          #4 0x5fd06dca6e3e in ha_create_table_from_share(THD*, TABLE_SHARE*, HA_CREATE_INFO*, unsigned int*) /test/bb-12.2-nikita-global-tmp_opt_san/sql/handler.cc:6427:26
          #5 0x5fd06dca5879 in ha_create_table(THD*, char const*, char const*, char const*, HA_CREATE_INFO*, st_mysql_const_unsigned_lex_string*, bool) /test/bb-12.2-nikita-global-tmp_opt_san/sql/handler.cc:6494:15
          #6 0x5fd06f09205e in create_table_impl(THD*, st_ddl_log_state*, st_ddl_log_state*, Lex_ident_db const&, Lex_ident_table const&, Lex_ident_db const&, Lex_ident_table const&, st_mysql_const_lex_string const&, DDL_options_st, HA_CREATE_INFO*, Alter_info*, int, bool*, st_key**, unsigned int*, st_mysql_const_unsigned_lex_string*) /test/bb-12.2-nikita-global-tmp_opt_san/sql/sql_table.cc:5017:11
          #7 0x5fd06f08eeea in mysql_create_table_no_lock(THD*, st_ddl_log_state*, st_ddl_log_state*, Table_specification_st*, Alter_info*, bool*, int, TABLE_LIST*) /test/bb-12.2-nikita-global-tmp_opt_san/sql/sql_table.cc:5119:8
          #8 0x5fd06f096ca2 in open_global_temporary_table(THD*, TABLE_SHARE*, TABLE_LIST*, MDL_ticket*) /test/bb-12.2-nikita-global-tmp_opt_san/sql/sql_table.cc:6311:14
          #9 0x5fd06e6a32ae in open_table(THD*, TABLE_LIST*, Open_table_context*) /test/bb-12.2-nikita-global-tmp_opt_san/sql/sql_base.cc:2351:22
          #10 0x5fd06e6b59a4 in open_and_process_table(THD*, TABLE_LIST*, unsigned int*, unsigned int, Prelocking_strategy*, bool, Open_table_context*) /test/bb-12.2-nikita-global-tmp_opt_san/sql/sql_base.cc:4308:14
          #11 0x5fd06e6b59a4 in open_tables(THD*, DDL_options_st const&, TABLE_LIST**, unsigned int*, unsigned int, Prelocking_strategy*) /test/bb-12.2-nikita-global-tmp_opt_san/sql/sql_base.cc:4791:14
          #12 0x5fd06e6c3d45 in open_and_lock_tables(THD*, DDL_options_st const&, TABLE_LIST*, bool, unsigned int, Prelocking_strategy*) /test/bb-12.2-nikita-global-tmp_opt_san/sql/sql_base.cc:5779:7
          #13 0x5fd06e172ea3 in open_and_lock_tables(THD*, TABLE_LIST*, bool, unsigned int) /test/bb-12.2-nikita-global-tmp_opt_san/sql/sql_base.h:544:10
          #14 0x5fd06ea3c8dd in mysql_insert(THD*, TABLE_LIST*, List<Item>&, List<List<Item>>&, List<Item>&, List<Item>&, enum_duplicates, bool, select_result*) /test/bb-12.2-nikita-global-tmp_opt_san/sql/sql_insert.cc:789:9
          #15 0x5fd06ebafa6a in mysql_execute_command(THD*, bool) /test/bb-12.2-nikita-global-tmp_opt_san/sql/sql_parse.cc:4460:10
          #16 0x5fd06eb8b545 in mysql_parse(THD*, char*, unsigned int, Parser_state*) /test/bb-12.2-nikita-global-tmp_opt_san/sql/sql_parse.cc:7895:18
          #17 0x5fd06eb83708 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool) /test/bb-12.2-nikita-global-tmp_opt_san/sql/sql_parse.cc:1882:7
          #18 0x5fd06eb8d480 in do_command(THD*, bool) /test/bb-12.2-nikita-global-tmp_opt_san/sql/sql_parse.cc:1421:17
          #19 0x5fd06f3b848c in do_handle_one_connection(CONNECT*, bool) /test/bb-12.2-nikita-global-tmp_opt_san/sql/sql_connect.cc:1414:11
          #20 0x5fd06f3b7fa6 in handle_one_connection /test/bb-12.2-nikita-global-tmp_opt_san/sql/sql_connect.cc:1326:5
          #21 0x5fd06db6c5ea in asan_thread_start(void*) crtstuff.c
          #22 0x78034729ca93 in start_thread nptl/pthread_create.c:447:8
          #23 0x780347329c3b in clone3 misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
       
      SUMMARY: UndefinedBehaviorSanitizer: invalid-enum-load /test/bb-12.2-nikita-global-tmp_opt_san/storage/mroonga/ha_mroonga.cpp:3640:14 
      

      Attachments

        Issue Links

          Activity

            People

              nikitamalyavin Nikita Malyavin
              Roel Roel Van de Paar
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated: