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

UBSAN: runtime error: call to function init_simple_key_cache 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)

      Installing MariaDB/MySQL system tables in '/test/UBASAN_MD271124-mariadb-10.6.21-linux-x86_64-dbg/data' ...
      /test/10.6_dbg_san/mysys/mf_keycache.c:5950:11: runtime error: call to function init_simple_key_cache through pointer to incorrect function type 'int (*)(void *, unsigned int, unsigned long, unsigned int, unsigned int, unsigned int)'
      /test/10.6_dbg_san/mysys/mf_keycache.c:480: note: init_simple_key_cache defined here
          #0 0x564b85abc73c in init_key_cache_internal /test/10.6_dbg_san/mysys/mf_keycache.c:5950:11
          #1 0x564b85abbc61 in init_key_cache /test/10.6_dbg_san/mysys/mf_keycache.c:6010:10
          #2 0x564b81e7a80c in ha_init_key_cache /test/10.6_dbg_san/sql/handler.cc:6135:5
          #3 0x564b7f07226f in process_key_caches(int (*)(char const*, st_key_cache*, void*), void*) /test/10.6_dbg_san/sql/keycaches.cc:180:12
          #4 0x564b7f0229f7 in init_server_components() /test/10.6_dbg_san/sql/mysqld.cc:5143:3
          #5 0x564b7f016ab0 in mysqld_main(int, char**) /test/10.6_dbg_san/sql/mysqld.cc:5806:7
          #6 0x564b7f001863 in main /test/10.6_dbg_san/sql/main.cc:34:10
          #7 0x14f7dde2a1c9 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
          #8 0x14f7dde2a28a in __libc_start_main csu/../csu/libc-start.c:360:3
          #9 0x564b7ef26034 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/mf_keycache.c:5950:11 
      

      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. Present in debug builds only.

      Attachments

        Issue Links

          Activity

            People

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