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

UBSAN: runtime error: call to function mysql_sys_var_int through pointer to incorrect function type in spider_param_force_commit

    XMLWordPrintable

Details

    Description

      INSTALL PLUGIN Spider SONAME 'ha_spider.so';
      CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET '../socket.sock',DATABASE 'a',user 'Spider',PASSWORD '');
      CREATE TABLE t1 (c CHAR) ENGINE=Spider COMMENT='WRAPPER "mysql",srv "srv",TABLE "t"';
      XA START 'xa1';
      SELECT 1 FROM t1;
      

      Leads to:

      CS 10.5.28 a226f12675c6312ca7632b90261397e313e6a7ae (Debug, UBASAN, Clang)

      /test/10.5_dbg_san/storage/spider/spd_param.cc:411: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 0x14c10479563a in spider_param_force_commit(THD*) /test/10.5_dbg_san/storage/spider/spd_param.cc:411:1
          #1 0x14c10487586e in spider_internal_xa_rollback(THD*, st_spider_transaction*) /test/10.5_dbg_san/storage/spider/spd_trx.cc:1999:23
          #2 0x14c1048882be in spider_rollback(handlerton*, THD*, bool) /test/10.5_dbg_san/storage/spider/spd_trx.cc:3203:28
          #3 0x55ff4f134314 in ha_rollback_trans(THD*, bool) /test/10.5_dbg_san/sql/handler.cc:2155:17
          #4 0x55ff4e793d8c in xa_trans_force_rollback(THD*) /test/10.5_dbg_san/sql/xa.cc:405:7
          #5 0x55ff4e7ac959 in trans_xa_detach(THD*) /test/10.5_dbg_san/sql/xa.cc:906:12
          #6 0x55ff4cb2b2ad in THD::cleanup() /test/10.5_dbg_san/sql/sql_class.cc:1556:5
          #7 0x55ff4c4678f3 in unlink_thd(THD*) /test/10.5_dbg_san/sql/mysqld.cc:2627:8
          #8 0x55ff4df20418 in do_handle_one_connection(CONNECT*, bool) /test/10.5_dbg_san/sql/sql_connect.cc:1397:5
          #9 0x55ff4df1e88d in handle_one_connection /test/10.5_dbg_san/sql/sql_connect.cc:1298:5
          #10 0x55ff4c417a8c in asan_thread_start(void*) asan_interceptors.cpp.o
          #11 0x14c137c9ca93 in start_thread nptl/pthread_create.c:447:8
          #12 0x14c137d29c3b 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:411:1 
      

      cmake command:

      cmake . -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++ -DWITH_SSL=bundled -DBUILD_CONFIG=mysql_release -DWITH_TOKUDB=0 -DWITH_JEMALLOC=no -DFEATURE_SET=community -DDEBUG_EXTNAME=OFF -DWITH_EMBEDDED_SERVER=0 -DENABLE_DOWNLOADS=1 -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/tmp/boost_763314 -DENABLED_LOCAL_INFILE=1 -DENABLE_DTRACE=0 -DWITH_SAFEMALLOC=OFF -DPLUGIN_PERFSCHEMA=NO -DWITH_DBUG_TRACE=OFF -DWITH_ZLIB=bundled -DWITH_ROCKSDB=1 -DWITH_PAM=ON -DWITH_MARIABACKUP=0 -DFORCE_INSOURCE_BUILD=1 -DWITH_ASAN=ON -DWITH_ASAN_SCOPE=ON -DWITH_UBSAN=ON -DWSREP_LIB_WITH_ASAN=ON -DCMAKE_CXX_FLAGS=-fsanitize-coverage=trace-pc-guard -DMYSQL_MAINTAINER_MODE=OFF -DWARNING_AS_ERROR='' -DCMAKE_BUILD_TYPE=Debug
      

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