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

UBSAN: runtime error: call to function adjust_optimizer_costs() 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 11.7.1 d4d5bce2da0d22b25485da3904f9f5fc11d7fcd4 (Debug, UBASAN)

      /test/11.7_dbg_san/sql/keycaches.cc:330:12: runtime error: call to function adjust_optimizer_costs(void*, OPTIMIZER_COSTS*, void*) through pointer to incorrect function type 'int (*)(const st_mysql_const_lex_string *, const OPTIMIZER_COSTS *, TABLE *)'
      /test/11.7_dbg_san/sql/mysqld.cc:4928: note: adjust_optimizer_costs(void*, OPTIMIZER_COSTS*, void*) defined here
          #0 0x55bdcb57b92c in process_optimizer_costs /test/11.7_dbg_san/sql/keycaches.cc:330:12
          #1 0x55bdcb5090a1 in init_server_components() /test/11.7_dbg_san/sql/mysqld.cc:5310:5
          #2 0x55bdcb4fcb1c in mysqld_main(int, char**) /test/11.7_dbg_san/sql/mysqld.cc:6019:7
          #3 0x55bdcb4e74a3 in main /test/11.7_dbg_san/sql/main.cc:34:10
          #4 0x150406a2a1c9 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
          #5 0x150406a2a28a in __libc_start_main csu/../csu/libc-start.c:360:3
          #6 0x55bdcb40bc74 in _start (/test/UBASAN_MD271124-mariadb-11.7.1-linux-x86_64-dbg/bin/mariadbd+0x420ac74) (BuildId: 4ffc5d87b420973421d7e440cab2c81981d3640e)
       
      SUMMARY: UndefinedBehaviorSanitizer: function-type-mismatch /test/11.7_dbg_san/sql/keycaches.cc:330:12
      

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