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

UBSAN: function-type-mismatch in spider_param_conn_recycle[_mode/_strict], spider_param_internal_xa_snapshot, and spider_param_block_size

    XMLWordPrintable

Details

    Description

      INSTALL SONAME 'ha_spider';
      CREATE TABLE t1 (c DATE) ENGINE=InnoDB;
      CREATE TABLE ts (c DATE) ENGINE=Spider COMMENT='DATABASE "test",table "t1"' CONNECTION='host "localhost",socket "../socket.sock",USER "Spider",PASSWORD ""';
      SELECT DISTINCT DATE_FORMAT(c,'%Y-%m-%d %H:%i:%s') FROM ts;
      

      Leads to:
      (Note: SIGSEGV stacks resolved by MDEV-35422 removed)

      CS 10.5.28 142851f1205d98270b917a98e1bdd483e1b8af0e (Debug, UBASAN, Clang)

      SUMMARY: UndefinedBehaviorSanitizer: function-type-mismatch /test/10.5_dbg_san/storage/myisam/ha_myisam.cc:1340:11 
      /test/10.5_dbg_san/storage/spider/spd_param.cc:309:1: runtime error: call to function mysql_sys_var_int(THD*, int) through pointer to incorrect function type 'unsigned int *(*)(THD *, int)'
      /test/10.5_dbg_san/sql/sql_plugin.cc:3226: note: mysql_sys_var_int(THD*, int) defined here
          #0 0x1457b0b94eaa in spider_param_conn_recycle_mode(THD*) /test/10.5_dbg_san/storage/spider/spd_param.cc:309:1
          #1 0x1457b0e68d6e in spider_get_conn(st_spider_share*, int, char*, st_spider_transaction*, ha_spider*, bool, bool, unsigned int, int*) /test/10.5_dbg_san/storage/spider/spd_conn.cc:678:12
          #2 0x1457b0fc163f in spider_get_share(char const*, TABLE*, THD*, ha_spider*, int*) /test/10.5_dbg_san/storage/spider/spd_table.cc:4614:13
          #3 0x1457b1139999 in ha_spider::open(char const*, int, unsigned int) /test/10.5_dbg_san/storage/spider/ha_spider.cc:310:18
          #4 0x5597668689b2 in handler::ha_open(TABLE*, char const*, int, unsigned int, st_mem_root*, List<String>*) /test/10.5_dbg_san/sql/handler.cc:3100:7
          #5 0x55976533cbaf in open_table_from_share(THD*, TABLE_SHARE*, st_mysql_const_lex_string const*, unsigned int, unsigned int, unsigned int, TABLE*, bool, List<String>*) /test/10.5_dbg_san/sql/table.cc:4325:33
          #6 0x5597640ca635 in open_table(THD*, TABLE_LIST*, Open_table_context*) /test/10.5_dbg_san/sql/sql_base.cc:2024:12
          #7 0x5597640f7eb7 in open_and_process_table(THD*, TABLE_LIST*, unsigned int*, unsigned int, Prelocking_strategy*, bool, Open_table_context*) /test/10.5_dbg_san/sql/sql_base.cc:3819:14
          #8 0x5597640ea759 in open_tables(THD*, DDL_options_st const&, TABLE_LIST**, unsigned int*, unsigned int, Prelocking_strategy*) /test/10.5_dbg_san/sql/sql_base.cc:4303:14
          #9 0x55976411496a in open_and_lock_tables(THD*, DDL_options_st const&, TABLE_LIST*, bool, unsigned int, Prelocking_strategy*) /test/10.5_dbg_san/sql/sql_base.cc:5250:7
          #10 0x559763e4fce6 in open_and_lock_tables(THD*, TABLE_LIST*, bool, unsigned int) /test/10.5_dbg_san/sql/sql_base.h:508:10
          #11 0x559764764f0b in execute_sqlcom_select(THD*, TABLE_LIST*) /test/10.5_dbg_san/sql/sql_parse.cc:6358:14
          #12 0x5597646fd59f in mysql_execute_command(THD*) /test/10.5_dbg_san/sql/sql_parse.cc:4029:12
          #13 0x5597646a44e3 in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /test/10.5_dbg_san/sql/sql_parse.cc:8237:18
          #14 0x559764684453 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /test/10.5_dbg_san/sql/sql_parse.cc:1891:7
          #15 0x5597646aca19 in do_command(THD*) /test/10.5_dbg_san/sql/sql_parse.cc:1375:17
          #16 0x559765626f30 in do_handle_one_connection(CONNECT*, bool) /test/10.5_dbg_san/sql/sql_connect.cc:1386:11
          #17 0x5597656256fd in handle_one_connection /test/10.5_dbg_san/sql/sql_connect.cc:1298:5
          #18 0x559763b20a8c in asan_thread_start(void*) asan_interceptors.cpp.o
          #19 0x1457e309ca93 in start_thread nptl/pthread_create.c:447:8
          #20 0x1457e3129c3b in clone3 misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
       
      SUMMARY: UndefinedBehaviorSanitizer: function-type-mismatch /test/10.5_dbg_san/storage/spider/spd_param.cc:309:1 
      

      CS 10.5.28 142851f1205d98270b917a98e1bdd483e1b8af0e (Debug, UBASAN, Clang)

      /test/10.5_dbg_san/storage/spider/spd_param.cc:327:1: runtime error: call to function mysql_sys_var_int(THD*, int) through pointer to incorrect function type 'unsigned int *(*)(THD *, int)'
      /test/10.5_dbg_san/sql/sql_plugin.cc:3226: note: mysql_sys_var_int(THD*, int) defined here
          #0 0x1457b0b94fea in spider_param_conn_recycle_strict(THD*) /test/10.5_dbg_san/storage/spider/spd_param.cc:327:1
          #1 0x1457b0e68e72 in spider_get_conn(st_spider_share*, int, char*, st_spider_transaction*, ha_spider*, bool, bool, unsigned int, int*) /test/10.5_dbg_san/storage/spider/spd_conn.cc:679:11
          #2 0x1457b0fc163f in spider_get_share(char const*, TABLE*, THD*, ha_spider*, int*) /test/10.5_dbg_san/storage/spider/spd_table.cc:4614:13
          #3 0x1457b1139999 in ha_spider::open(char const*, int, unsigned int) /test/10.5_dbg_san/storage/spider/ha_spider.cc:310:18
          #4 0x5597668689b2 in handler::ha_open(TABLE*, char const*, int, unsigned int, st_mem_root*, List<String>*) /test/10.5_dbg_san/sql/handler.cc:3100:7
          #5 0x55976533cbaf in open_table_from_share(THD*, TABLE_SHARE*, st_mysql_const_lex_string const*, unsigned int, unsigned int, unsigned int, TABLE*, bool, List<String>*) /test/10.5_dbg_san/sql/table.cc:4325:33
          #6 0x5597640ca635 in open_table(THD*, TABLE_LIST*, Open_table_context*) /test/10.5_dbg_san/sql/sql_base.cc:2024:12
          #7 0x5597640f7eb7 in open_and_process_table(THD*, TABLE_LIST*, unsigned int*, unsigned int, Prelocking_strategy*, bool, Open_table_context*) /test/10.5_dbg_san/sql/sql_base.cc:3819:14
          #8 0x5597640ea759 in open_tables(THD*, DDL_options_st const&, TABLE_LIST**, unsigned int*, unsigned int, Prelocking_strategy*) /test/10.5_dbg_san/sql/sql_base.cc:4303:14
          #9 0x55976411496a in open_and_lock_tables(THD*, DDL_options_st const&, TABLE_LIST*, bool, unsigned int, Prelocking_strategy*) /test/10.5_dbg_san/sql/sql_base.cc:5250:7
          #10 0x559763e4fce6 in open_and_lock_tables(THD*, TABLE_LIST*, bool, unsigned int) /test/10.5_dbg_san/sql/sql_base.h:508:10
          #11 0x559764764f0b in execute_sqlcom_select(THD*, TABLE_LIST*) /test/10.5_dbg_san/sql/sql_parse.cc:6358:14
          #12 0x5597646fd59f in mysql_execute_command(THD*) /test/10.5_dbg_san/sql/sql_parse.cc:4029:12
          #13 0x5597646a44e3 in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /test/10.5_dbg_san/sql/sql_parse.cc:8237:18
          #14 0x559764684453 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /test/10.5_dbg_san/sql/sql_parse.cc:1891:7
          #15 0x5597646aca19 in do_command(THD*) /test/10.5_dbg_san/sql/sql_parse.cc:1375:17
          #16 0x559765626f30 in do_handle_one_connection(CONNECT*, bool) /test/10.5_dbg_san/sql/sql_connect.cc:1386:11
          #17 0x5597656256fd in handle_one_connection /test/10.5_dbg_san/sql/sql_connect.cc:1298:5
          #18 0x559763b20a8c in asan_thread_start(void*) asan_interceptors.cpp.o
          #19 0x1457e309ca93 in start_thread nptl/pthread_create.c:447:8
          #20 0x1457e3129c3b in clone3 misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
       
      SUMMARY: UndefinedBehaviorSanitizer: function-type-mismatch /test/10.5_dbg_san/storage/spider/spd_param.cc:327:1 
      

      CS 10.5.28 142851f1205d98270b917a98e1bdd483e1b8af0e (Debug, UBASAN, Clang)

      /test/10.5_dbg_san/storage/spider/spd_param.cc:392:1: runtime error: call to function mysql_sys_var_int(THD*, int) through pointer to incorrect function type 'unsigned int *(*)(THD *, int)'
      /test/10.5_dbg_san/sql/sql_plugin.cc:3226: note: mysql_sys_var_int(THD*, int) defined here
          #0 0x1457b0b954ea in spider_param_internal_xa_snapshot(THD*) /test/10.5_dbg_san/storage/spider/spd_param.cc:392:1
          #1 0x1457b0c6d7cb in spider_internal_start_trx(ha_spider*) /test/10.5_dbg_san/storage/spider/spd_trx.cc:1610:35
          #2 0x1457b1171e20 in ha_spider::external_lock(THD*, int) /test/10.5_dbg_san/storage/spider/ha_spider.cc:969:9
          #3 0x55976686cbbe in handler::ha_external_lock(THD*, int) /test/10.5_dbg_san/sql/handler.cc:6833:3
          #4 0x55976744ec34 in lock_external(THD*, TABLE**, unsigned int) /test/10.5_dbg_san/sql/lock.cc:396:9
          #5 0x55976744b816 in mysql_lock_tables(THD*, st_mysql_lock*, unsigned int) /test/10.5_dbg_san/sql/lock.cc:341:32
          #6 0x559767443b8b in mysql_lock_tables(THD*, TABLE**, unsigned int, unsigned int) /test/10.5_dbg_san/sql/lock.cc:304:7
          #7 0x55976410a67e in lock_tables(THD*, TABLE_LIST*, unsigned int, unsigned int) /test/10.5_dbg_san/sql/sql_base.cc:5504:23
          #8 0x559764114f80 in open_and_lock_tables(THD*, DDL_options_st const&, TABLE_LIST*, bool, unsigned int, Prelocking_strategy*) /test/10.5_dbg_san/sql/sql_base.cc:5259:7
          #9 0x559763e4fce6 in open_and_lock_tables(THD*, TABLE_LIST*, bool, unsigned int) /test/10.5_dbg_san/sql/sql_base.h:508:10
          #10 0x559764764f0b in execute_sqlcom_select(THD*, TABLE_LIST*) /test/10.5_dbg_san/sql/sql_parse.cc:6358:14
          #11 0x5597646fd59f in mysql_execute_command(THD*) /test/10.5_dbg_san/sql/sql_parse.cc:4029:12
          #12 0x5597646a44e3 in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /test/10.5_dbg_san/sql/sql_parse.cc:8237:18
          #13 0x559764684453 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /test/10.5_dbg_san/sql/sql_parse.cc:1891:7
          #14 0x5597646aca19 in do_command(THD*) /test/10.5_dbg_san/sql/sql_parse.cc:1375:17
          #15 0x559765626f30 in do_handle_one_connection(CONNECT*, bool) /test/10.5_dbg_san/sql/sql_connect.cc:1386:11
          #16 0x5597656256fd in handle_one_connection /test/10.5_dbg_san/sql/sql_connect.cc:1298:5
          #17 0x559763b20a8c in asan_thread_start(void*) asan_interceptors.cpp.o
          #18 0x1457e309ca93 in start_thread nptl/pthread_create.c:447:8
          #19 0x1457e3129c3b in clone3 misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
       
      SUMMARY: UndefinedBehaviorSanitizer: function-type-mismatch /test/10.5_dbg_san/storage/spider/spd_param.cc:392:1 
      

      CS 10.5.28 142851f1205d98270b917a98e1bdd483e1b8af0e (Debug, UBASAN, Clang)

      /test/10.5_dbg_san/storage/spider/spd_param.cc:741:1: runtime error: call to function mysql_sys_var_int(THD*, int) through pointer to incorrect function type 'unsigned int *(*)(THD *, int)'
      /test/10.5_dbg_san/sql/sql_plugin.cc:3226: note: mysql_sys_var_int(THD*, int) defined here
          #0 0x1457b0b976da in spider_param_block_size(THD*) /test/10.5_dbg_san/storage/spider/spd_param.cc:741:1
          #1 0x1457b1259521 in ha_spider::info(unsigned int) /test/10.5_dbg_san/storage/spider/ha_spider.cc:5943:26
          #2 0x5597653e41bd in TABLE_LIST::fetch_number_of_rows() /test/10.5_dbg_san/sql/table.cc:9550:25
          #3 0x559764a1fd79 in make_join_statistics(JOIN*, List<TABLE_LIST>&, st_dynamic_array*) /test/10.5_dbg_san/sql/sql_select.cc:5147:20
          #4 0x559764a03095 in JOIN::optimize_inner() /test/10.5_dbg_san/sql/sql_select.cc:2416:7
          #5 0x5597649e002d in JOIN::optimize() /test/10.5_dbg_san/sql/sql_select.cc:1765:10
          #6 0x5597649909db in 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*) /test/10.5_dbg_san/sql/sql_select.cc:4904:19
          #7 0x55976498d0c7 in handle_select(THD*, LEX*, select_result*, unsigned long) /test/10.5_dbg_san/sql/sql_select.cc:449:10
          #8 0x5597647693f0 in execute_sqlcom_select(THD*, TABLE_LIST*) /test/10.5_dbg_san/sql/sql_parse.cc:6437:12
          #9 0x5597646fd59f in mysql_execute_command(THD*) /test/10.5_dbg_san/sql/sql_parse.cc:4029:12
          #10 0x5597646a44e3 in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /test/10.5_dbg_san/sql/sql_parse.cc:8237:18
          #11 0x559764684453 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /test/10.5_dbg_san/sql/sql_parse.cc:1891:7
          #12 0x5597646aca19 in do_command(THD*) /test/10.5_dbg_san/sql/sql_parse.cc:1375:17
          #13 0x559765626f30 in do_handle_one_connection(CONNECT*, bool) /test/10.5_dbg_san/sql/sql_connect.cc:1386:11
          #14 0x5597656256fd in handle_one_connection /test/10.5_dbg_san/sql/sql_connect.cc:1298:5
          #15 0x559763b20a8c in asan_thread_start(void*) asan_interceptors.cpp.o
          #16 0x1457e309ca93 in start_thread nptl/pthread_create.c:447:8
          #17 0x1457e3129c3b in clone3 misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
       
      SUMMARY: UndefinedBehaviorSanitizer: function-type-mismatch /test/10.5_dbg_san/storage/spider/spd_param.cc:741:1 
      

      (Note: UBSAN runtime error: member call on null pointer of type 'Item' in spider_db_print_item_type stack resolved by MDEV-35422 removed)

      Setup:

      Compiled with a recent version of Clang (I used Clang 18.1.3) with LLVM 18:
           # 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 other UBSAN 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 - just remember to remove the errors seen in this report.
      

      Bug confirmed present in:
      MariaDB: 10.5.28 (dbg), 10.5.28 (opt), 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)

      Attachments

        Issue Links

          Activity

            People

              bnestere Brandon Nesterenko
              Roel Roel Van de Paar
              Votes:
              0 Vote for this issue
              Watchers:
              3 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.