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

UBSAN: runtime error: call to function get_sys_var_length on server startup or version query

    XMLWordPrintable

Details

    Description

      On server startup or version query:

      $ ./bin/mariadbd --version 
      

      We see:

      CS 10.6.21 2255be03952e0be7db764613956c5c66a6c1ab75 (Debug, UBASAN)

      /test/10.6_dbg_san/mysys/hash.c:197:20: runtime error: call to function get_sys_var_length(sys_var const*, unsigned long*, char) through pointer to incorrect function type 'unsigned char *(*)(const unsigned char *, unsigned long *, char)'
      /test/10.6_dbg_san/sql/set_var.cc:53: note: get_sys_var_length(sys_var const*, unsigned long*, char) defined here
          #0 0x55c6cbbad746 in my_hash_key /test/10.6_dbg_san/mysys/hash.c:197:20
          #1 0x55c6cbbab25b in my_hash_insert /test/10.6_dbg_san/mysys/hash.c:397:17
          #2 0x55c6c5246eed in mysql_add_sys_var_chain(sys_var*) /test/10.6_dbg_san/sql/set_var.cc:572:9
          #3 0x55c6c5246938 in sys_var_init() /test/10.6_dbg_san/sql/set_var.cc:71:7
          #4 0x55c6c51433c1 in mysqld_main(int, char**) /test/10.6_dbg_san/sql/mysqld.cc:5613:3
          #5 0x55c6c512e863 in main /test/10.6_dbg_san/sql/main.cc:34:10
          #6 0x153b20a2a1c9 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
          #7 0x153b20a2a28a in __libc_start_main csu/../csu/libc-start.c:360:3
          #8 0x55c6c5053034 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:197:20 
      ./bin/mariadbd  Ver 10.6.21-MariaDB-debug for Linux on x86_64 (MariaDB Server)
      

      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.