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

runtime error: call to function mysql_sys_var_int through pointer to incorrect function type in thd_lock_wait_timeout on ALTER

    XMLWordPrintable

Details

    Description

      Additional function-type-mismatch in thd_lock_wait_timeout

      CREATE TABLE t (c INT) ENGINE=InnoDB;
      INSERT t VALUES (0),(0);
      ALTER TABLE t ADD UNIQUE INDEX(c);
      

      Leads to:

      CS 11.8.0 7734c85c31c9e292ef1133115fba2f7edd71dd51 (Optimized, UBASAN, Clang)

      /test/11.8_opt_san/storage/innobase/handler/ha_innodb.cc:1851:9: runtime error: call to function mysql_sys_var_int(THD*, int) through pointer to incorrect function type 'unsigned int *(*)(THD *, int)'
      /test/11.8_opt_san/sql/sql_plugin.cc:3218: note: mysql_sys_var_int(THD*, int) defined here
          #0 0x564b0f0b3fd2 in thd_lock_wait_timeout(THD*) /test/11.8_opt_san/storage/innobase/handler/ha_innodb.cc:1851:9
          #1 0x564b0f1d58b7 in rollback_inplace_alter_table(Alter_inplace_info*, TABLE const*, row_prebuilt_t*) /test/11.8_opt_san/storage/innobase/handler/handler0alter.cc:9205:9
          #2 0x564b0f1c61cc in ha_innobase::commit_inplace_alter_table(TABLE*, Alter_inplace_info*, bool) /test/11.8_opt_san/storage/innobase/handler/handler0alter.cc:11278:3
          #3 0x564b0d535481 in mysql_inplace_alter_table(THD*, TABLE_LIST*, TABLE*, TABLE*, Alter_inplace_info*, MDL_request*, st_ddl_log_state*, TRIGGER_RENAME_PARAM*, Alter_table_ctx*, bool&, unsigned long long&, bool) /test/11.8_opt_san/sql/sql_table.cc:8213:16
          #4 0x564b0d514462 in mysql_alter_table(THD*, st_mysql_const_lex_string const*, st_mysql_const_lex_string const*, Table_specification_st*, TABLE_LIST*, Recreate_info*, Alter_info*, unsigned int, st_order*, bool, bool) /test/11.8_opt_san/sql/sql_table.cc:11481:16
          #5 0x564b0d81d267 in Sql_cmd_alter_table::execute(THD*) /test/11.8_opt_san/sql/sql_alter.cc:701:11
          #6 0x564b0d039590 in mysql_execute_command(THD*, bool) /test/11.8_opt_san/sql/sql_parse.cc:5872:26
          #7 0x564b0d00bc92 in mysql_parse(THD*, char*, unsigned int, Parser_state*) /test/11.8_opt_san/sql/sql_parse.cc:7901:18
          #8 0x564b0d000b9e in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool) /test/11.8_opt_san/sql/sql_parse.cc:1903:7
          #9 0x564b0d00ea6e in do_command(THD*, bool) /test/11.8_opt_san/sql/sql_parse.cc:1416:17
          #10 0x564b0d7efe38 in do_handle_one_connection(CONNECT*, bool) /test/11.8_opt_san/sql/sql_connect.cc:1415:11
          #11 0x564b0d7ef280 in handle_one_connection /test/11.8_opt_san/sql/sql_connect.cc:1327:5
          #12 0x564b0c937b0c in asan_thread_start(void*) asan_interceptors.cpp.o
          #13 0x151cbac9ca93 in start_thread nptl/pthread_create.c:447:8
          #14 0x151cbad29c3b in clone3 misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
       
      SUMMARY: UndefinedBehaviorSanitizer: function-type-mismatch /test/11.8_opt_san/storage/innobase/handler/ha_innodb.cc:1851:9 
      

      CS 11.8.0 7734c85c31c9e292ef1133115fba2f7edd71dd51 (Debug, UBASAN, Clang)

      /test/11.8_dbg_san/storage/innobase/handler/ha_innodb.cc:1851:9: runtime error: call to function mysql_sys_var_int(THD*, int) through pointer to incorrect function type 'unsigned int *(*)(THD *, int)'
      /test/11.8_dbg_san/sql/sql_plugin.cc:3218: note: mysql_sys_var_int(THD*, int) defined here
          #0 0x55c257807c5a in thd_lock_wait_timeout(THD*) /test/11.8_dbg_san/storage/innobase/handler/ha_innodb.cc:1851:9
          #1 0x55c257b0467f in rollback_inplace_alter_table(Alter_inplace_info*, TABLE const*, row_prebuilt_t*) /test/11.8_dbg_san/storage/innobase/handler/handler0alter.cc:9205:9
          #2 0x55c257adc51f in ha_innobase::commit_inplace_alter_table(TABLE*, Alter_inplace_info*, bool) /test/11.8_dbg_san/storage/innobase/handler/handler0alter.cc:11278:3
          #3 0x55c255a295ef in handler::ha_commit_inplace_alter_table(TABLE*, Alter_inplace_info*, bool) /test/11.8_dbg_san/sql/handler.cc:5704:11
          #4 0x55c253f31c9a in mysql_inplace_alter_table(THD*, TABLE_LIST*, TABLE*, TABLE*, Alter_inplace_info*, MDL_request*, st_ddl_log_state*, TRIGGER_RENAME_PARAM*, Alter_table_ctx*, bool&, unsigned long long&, bool) /test/11.8_dbg_san/sql/sql_table.cc:8213:16
          #5 0x55c253ee1348 in mysql_alter_table(THD*, st_mysql_const_lex_string const*, st_mysql_const_lex_string const*, Table_specification_st*, TABLE_LIST*, Recreate_info*, Alter_info*, unsigned int, st_order*, bool, bool) /test/11.8_dbg_san/sql/sql_table.cc:11481:16
          #6 0x55c2545a8ed3 in Sql_cmd_alter_table::execute(THD*) /test/11.8_dbg_san/sql/sql_alter.cc:701:11
          #7 0x55c253477d67 in mysql_execute_command(THD*, bool) /test/11.8_dbg_san/sql/sql_parse.cc:5872:26
          #8 0x55c2533d4ef9 in mysql_parse(THD*, char*, unsigned int, Parser_state*) /test/11.8_dbg_san/sql/sql_parse.cc:7901:18
          #9 0x55c2533b5db8 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool) /test/11.8_dbg_san/sql/sql_parse.cc:1903:7
          #10 0x55c2533dee56 in do_command(THD*, bool) /test/11.8_dbg_san/sql/sql_parse.cc:1416:17
          #11 0x55c254541556 in do_handle_one_connection(CONNECT*, bool) /test/11.8_dbg_san/sql/sql_connect.cc:1415:11
          #12 0x55c25453fd19 in handle_one_connection /test/11.8_dbg_san/sql/sql_connect.cc:1327:5
          #13 0x55c2525885fc in asan_thread_start(void*) asan_interceptors.cpp.o
          #14 0x15306a49ca93 in start_thread nptl/pthread_create.c:447:8
          #15 0x15306a529c3b in clone3 misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
       
      SUMMARY: UndefinedBehaviorSanitizer: function-type-mismatch /test/11.8_dbg_san/storage/innobase/handler/ha_innodb.cc:1851:9 
      

      Setup:

      Compiled with a recent version of Clang (I used Clang 18.1.3) with LLVM 18. Ubuntu instructions:
           # Note: llvm-17-linker-tools installs /usr/lib/llvm-17/lib/LLVMgold.so, which is needed for compilation, and LLVMgold.so is no longer included in LLVM 18
           sudo apt install clang llvm-18 llvm-18-linker-tools llvm-18-runtime llvm-18-tools llvm-18-dev libstdc++-14-dev llvm-dev llvm-17-linker-tools
           sudo ln -s /usr/lib/llvm-17/lib/LLVMgold.so /usr/lib/llvm-18/lib/LLVMgold.so
      Compiled with: '-DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++' and:
          -DWITH_ASAN=ON -DWITH_ASAN_SCOPE=ON -DWITH_UBSAN=ON -DWSREP_LIB_WITH_ASAN=ON
      Set before execution:
          export UBSAN_OPTIONS=print_stacktrace=1:report_error_type=1   # And you may also want to supress UBSAN startup issues using 'suppressions=UBSAN.filter'. For an example of UBSAN.filter, which includes current startup issues see: https://github.com/mariadb-corporation/mariadb-qa/blob/master/UBSAN.filter
      

      Bug confirmed present in:
      10.6.21 (dbg), 10.6.21 (opt), 10.11.11 (dbg), 10.11.11 (opt), 11.4.5 (dbg), 11.4.5 (opt), 11.7.1 (dbg), 11.7.1 (opt), 11.8.0 (dbg), 11.8.0 (opt)

      Bug (or feature/syntax) confirmed not present in:
      MariaDB: 10.5.28 (dbg), 10.5.28 (opt)

      Attachments

        Issue Links

          Activity

            People

              bnestere Brandon Nesterenko
              Roel Roel Van de Paar
              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.