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

UBSAN: runtime error: call to function FT_STOPWORD_cmp through pointer to incorrect function

    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/tree.c:249:9: runtime error: call to function FT_STOPWORD_cmp through pointer to incorrect function type 'int (*)(void *, const void *, const void *)'
      /test/10.6_dbg_san/storage/myisam/ft_stopwords.c:35: note: FT_STOPWORD_cmp defined here
          #0 0x560383995267 in tree_insert /test/10.6_dbg_san/mysys/tree.c:249:9
          #1 0x56038358458a in ft_add_stopword /test/10.6_dbg_san/storage/myisam/ft_stopwords.c:54:12
          #2 0x560383583f54 in ft_init_stopwords /test/10.6_dbg_san/storage/myisam/ft_stopwords.c:118:11
          #3 0x56037ce15b7f in init_server_components() /test/10.6_dbg_san/sql/mysqld.cc:5501:3
          #4 0x56037ce07ab0 in mysqld_main(int, char**) /test/10.6_dbg_san/sql/mysqld.cc:5806:7
          #5 0x56037cdf2863 in main /test/10.6_dbg_san/sql/main.cc:34:10
          #6 0x14dcc422a1c9 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
          #7 0x14dcc422a28a in __libc_start_main csu/../csu/libc-start.c:360:3
          #8 0x56037cd17034 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/tree.c:249:9 
      

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