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

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

      /test/10.6_dbg_san/mysys/mf_keycache.c:6152:5: runtime error: call to function end_simple_key_cache through pointer to incorrect function type 'void (*)(void *, char)'
      /test/10.6_dbg_san/mysys/mf_keycache.c:957: note: end_simple_key_cache defined here
          #0 0x5629e6b5a173 in end_key_cache_internal /test/10.6_dbg_san/mysys/mf_keycache.c:6152:5
          #1 0x5629e6b59fab in end_key_cache /test/10.6_dbg_san/mysys/mf_keycache.c:6195:3
          #2 0x5629e010dd21 in free_key_cache(char const*, void*) /test/10.6_dbg_san/sql/keycaches.cc:166:3
          #3 0x5629e010c9f5 in NAMED_ILIST::delete_elements(void (*)(char const*, void*)) /test/10.6_dbg_san/sql/keycaches.cc:98:5
          #4 0x5629e00a69d6 in clean_up(bool) /test/10.6_dbg_san/sql/mysqld.cc:1980:14
          #5 0x5629e00a5951 in unireg_abort /test/10.6_dbg_san/sql/mysqld.cc:1896:3
          #6 0x5629e00b33b7 in mysqld_main(int, char**) /test/10.6_dbg_san/sql/mysqld.cc:5890:7
          #7 0x5629e009d863 in main /test/10.6_dbg_san/sql/main.cc:34:10
          #8 0x14a4df02a1c9 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
          #9 0x14a4df02a28a in __libc_start_main csu/../csu/libc-start.c:360:3
          #10 0x5629dffc2034 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:6152:5 
      

      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

              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.