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

runtime error: call to function spider_direct_sql and spider_flush_table_mon_cache through pointer to incorrect function type in udf_handler::val_int

    XMLWordPrintable

Details

    Description

      Additional function-type-mismatch.

      INSTALL PLUGIN Spider SONAME 'ha_spider.so';
      SELECT spider_direct_sql ('SELECT 1','','SRV "a"');
      

      Leads to:

      CS 11.8.0 7734c85c31c9e292ef1133115fba2f7edd71dd51 (Optimized, UBASAN, Clang)

      /test/11.8_opt_san/sql/sql_udf.h:104:18: runtime error: call to function spider_direct_sql through pointer to incorrect function type 'long long (*)(st_udf_init *, st_udf_args *, unsigned char *, unsigned char *)'
      /test/11.8_opt_san/storage/spider/spd_udf.cc:27: note: spider_direct_sql defined here
          #0 0x5573db856551 in udf_handler::val_int(char*) /test/11.8_opt_san/sql/sql_udf.h:104:18
          #1 0x5573db856551 in Item_func_udf_int::val_int() /test/11.8_opt_san/sql/item_func.cc:3860:12
          #2 0x5573daff2a71 in Type_handler::Item_send_longlong(Item*, Protocol*, st_value*) const /test/11.8_opt_san/sql/sql_type.cc:7706:22
          #3 0x5573d9ee6e04 in Protocol::send_result_set_row(List<Item>*) /test/11.8_opt_san/sql/protocol.cc:1353:15
          #4 0x5573da1b06a3 in select_send::send_data(List<Item>&) /test/11.8_opt_san/sql/sql_class.cc:3275:17
          #5 0x5573da65b648 in JOIN::exec_inner() /test/11.8_opt_san/sql/sql_select.cc:4908:22
          #6 0x5573da656e21 in JOIN::exec() /test/11.8_opt_san/sql/sql_select.cc:4820:8
          #7 0x5573da5b3a2b 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/11.8_opt_san/sql/sql_select.cc:5353:21
          #8 0x5573da5b1c4d in handle_select(THD*, LEX*, select_result*, unsigned long long) /test/11.8_opt_san/sql/sql_select.cc:633:10
          #9 0x5573da465dac in execute_sqlcom_select(THD*, TABLE_LIST*) /test/11.8_opt_san/sql/sql_parse.cc:6177:12
          #10 0x5573da44afc7 in mysql_execute_command(THD*, bool) /test/11.8_opt_san/sql/sql_parse.cc:3966:12
          #11 0x5573da413c92 in mysql_parse(THD*, char*, unsigned int, Parser_state*) /test/11.8_opt_san/sql/sql_parse.cc:7901:18
          #12 0x5573da408b9e in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool) /test/11.8_opt_san/sql/sql_parse.cc:1903:7
          #13 0x5573da416a6e in do_command(THD*, bool) /test/11.8_opt_san/sql/sql_parse.cc:1416:17
          #14 0x5573dabf7e38 in do_handle_one_connection(CONNECT*, bool) /test/11.8_opt_san/sql/sql_connect.cc:1415:11
          #15 0x5573dabf7280 in handle_one_connection /test/11.8_opt_san/sql/sql_connect.cc:1327:5
          #16 0x5573d9d3fb0c in asan_thread_start(void*) asan_interceptors.cpp.o
          #17 0x152d0ea9ca93 in start_thread nptl/pthread_create.c:447:8
          #18 0x152d0eb29c3b in clone3 misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
       
      SUMMARY: UndefinedBehaviorSanitizer: function-type-mismatch /test/11.8_opt_san/sql/sql_udf.h:104:18 
      

      CS 11.8.0 7734c85c31c9e292ef1133115fba2f7edd71dd51 (Debug, UBASAN, Clang)

      /test/11.8_dbg_san/sql/sql_udf.h:104:18: runtime error: call to function spider_direct_sql through pointer to incorrect function type 'long long (*)(st_udf_init *, st_udf_args *, unsigned char *, unsigned char *)'
      /test/11.8_dbg_san/storage/spider/spd_udf.cc:27: note: spider_direct_sql defined here
          #0 0x560ac2ab62dd in udf_handler::val_int(char*) /test/11.8_dbg_san/sql/sql_udf.h:104:18
          #1 0x560ac2ab5ead in Item_func_udf_int::val_int() /test/11.8_dbg_san/sql/item_func.cc:3860:12
          #2 0x560ac188947b in Type_handler::Item_send_longlong(Item*, Protocol*, st_value*) const /test/11.8_dbg_san/sql/sql_type.cc:7706:22
          #3 0x560ac18d641c in Type_handler_longlong::Item_send(Item*, Protocol*, st_value*) const /test/11.8_dbg_san/sql/sql_type.h:6085:12
          #4 0x560abf18b617 in Item::send(Protocol*, st_value*) /test/11.8_dbg_san/sql/item.h:1256:28
          #5 0x560abf435681 in Protocol::send_result_set_row(List<Item>*) /test/11.8_dbg_san/sql/protocol.cc:1353:15
          #6 0x560abfa7204a in select_send::send_data(List<Item>&) /test/11.8_dbg_san/sql/sql_class.cc:3275:17
          #7 0x560ac0473fd0 in select_result_sink::send_data_with_check(List<Item>&, st_select_lex_unit*, unsigned long long) /test/11.8_dbg_san/sql/sql_class.h:6244:12
          #8 0x560ac046e163 in JOIN::exec_inner() /test/11.8_dbg_san/sql/sql_select.cc:4908:22
          #9 0x560ac046a56a in JOIN::exec() /test/11.8_dbg_san/sql/sql_select.cc:4820:8
          #10 0x560ac0308a79 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/11.8_dbg_san/sql/sql_select.cc:5353:21
          #11 0x560ac0304137 in handle_select(THD*, LEX*, select_result*, unsigned long long) /test/11.8_dbg_san/sql/sql_select.cc:633:10
          #12 0x560abffefee0 in execute_sqlcom_select(THD*, TABLE_LIST*) /test/11.8_dbg_san/sql/sql_parse.cc:6177:12
          #13 0x560abff8fdcc in mysql_execute_command(THD*, bool) /test/11.8_dbg_san/sql/sql_parse.cc:3966:12
          #14 0x560abff35ef9 in mysql_parse(THD*, char*, unsigned int, Parser_state*) /test/11.8_dbg_san/sql/sql_parse.cc:7901:18
          #15 0x560abff16db8 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool) /test/11.8_dbg_san/sql/sql_parse.cc:1903:7
          #16 0x560abff3fe56 in do_command(THD*, bool) /test/11.8_dbg_san/sql/sql_parse.cc:1416:17
          #17 0x560ac10a2556 in do_handle_one_connection(CONNECT*, bool) /test/11.8_dbg_san/sql/sql_connect.cc:1415:11
          #18 0x560ac10a0d19 in handle_one_connection /test/11.8_dbg_san/sql/sql_connect.cc:1327:5
          #19 0x560abf0e95fc in asan_thread_start(void*) asan_interceptors.cpp.o
          #20 0x14621e89ca93 in start_thread nptl/pthread_create.c:447:8
          #21 0x14621e929c3b in clone3 misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
       
      SUMMARY: UndefinedBehaviorSanitizer: function-type-mismatch /test/11.8_dbg_san/sql/sql_udf.h:104:18 
      

      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:
      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:
              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.