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

UBSAN: runtime error: call to function free_user_var through pointer to incorrect function type

    XMLWordPrintable

Details

    Description

      export UBSAN_OPTIONS=print_stacktrace=1:report_error_type=1
      rm -Rf data tmp 
      mkdir tmp 
      ./scripts/mariadb-install-db --no-defaults --force --auth-root-authentication-method=normal --basedir=${PWD} --tmpdir=${PWD}/tmp --datadir=${PWD}/data
      

      Leads to:

      CS 10.6.21 2255be03952e0be7db764613956c5c66a6c1ab75 (Debug, UBASAN)

      /test/10.6_dbg_san/mysys/hash.c:135:7: runtime error: call to function free_user_var through pointer to incorrect function type 'void (*)(void *)'
      /test/10.6_dbg_san/sql/sql_class.cc:98: note: free_user_var defined here
          #0 0x5632f4ae7593 in my_hash_free_elements /test/10.6_dbg_san/mysys/hash.c:135:7
          #1 0x5632f4ae70e1 in my_hash_free /test/10.6_dbg_san/mysys/hash.c:157:3
          #2 0x5632ee747dab in THD::cleanup() /test/10.6_dbg_san/sql/sql_class.cc:1649:3
          #3 0x5632ee74f176 in THD::free_connection() /test/10.6_dbg_san/sql/sql_class.cc:1692:4
          #4 0x5632ee751e24 in THD::~THD() /test/10.6_dbg_san/sql/sql_class.cc:1780:5
          #5 0x5632ee7548df in THD::~THD() /test/10.6_dbg_san/sql/sql_class.cc:1751:1
          #6 0x5632eebcab5e in bootstrap(st_mysql_file*) /test/10.6_dbg_san/sql/sql_parse.cc:1111:3
          #7 0x5632ee082328 in mysqld_main(int, char**) /test/10.6_dbg_san/sql/mysqld.cc:5888:26
          #8 0x5632ee06c863 in main /test/10.6_dbg_san/sql/main.cc:34:10
          #9 0x148b1242a1c9 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
          #10 0x148b1242a28a in __libc_start_main csu/../csu/libc-start.c:360:3
          #11 0x5632edf91034 in _start (/test/UBASAN_MD271124-mariadb-10.6.21-linux-x86_64-dbg/bin/mariadbd+0x3eb8034) (BuildId: 3cd87cd3953ac9cf3a930328b34dbd55d44c8146)
       
      SUMMARY: UndefinedBehaviorSanitizer: function-type-mismatch /test/10.6_dbg_san/mysys/hash.c:135:7
      

      Observed using UBSAN with Clang and LLMV 18.1.3:

      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  # 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 ln -s /usr/lib/llvm-17/lib/LLVMgold.so /usr/lib/llvm-18/lib/LLVMgold.so
      ...
      export UBSAN_OPTIONS=print_stacktrace=1:report_error_type=1
      

      Related helpful comment on 'function-type-mismatch' errors here.

      Attachments

        Issue Links

          Activity

            People

              sanja Oleksandr Byelkin
              Roel Roel Van de Paar
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.