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

UBSAN: runtime error: call to function mhnsw_init(void*) through pointer to incorrect function type in plugin_do_initialize()

    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/sql_plugin.cc:1454:18: runtime error: call to function mhnsw_init(void*) through pointer to incorrect function type 'int (*)(st_plugin_int *)'
      /test/11.7_dbg_san/sql/vector_mhnsw.cc:1485: note: mhnsw_init(void*) defined here
          #0 0x5562a5085779 in plugin_do_initialize(st_plugin_int*, unsigned int&) /test/11.7_dbg_san/sql/sql_plugin.cc:1454:18
          #1 0x5562a5083b02 in plugin_initialize(st_mem_root*, st_plugin_int*, int*, char**, bool) /test/11.7_dbg_san/sql/sql_plugin.cc:1507:10
          #2 0x5562a5081928 in plugin_init(int*, char**, int) /test/11.7_dbg_san/sql/sql_plugin.cc:1751:18
          #3 0x5562a40a31c8 in init_server_components() /test/11.7_dbg_san/sql/mysqld.cc:5323:7
          #4 0x5562a4096b1c in mysqld_main(int, char**) /test/11.7_dbg_san/sql/mysqld.cc:6019:7
          #5 0x5562a40814a3 in main /test/11.7_dbg_san/sql/main.cc:34:10
          #6 0x1486eec2a1c9 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
          #7 0x1486eec2a28a in __libc_start_main csu/../csu/libc-start.c:360:3
          #8 0x5562a3fa5c74 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/sql_plugin.cc:1454:18
      

      And:

      CS 11.7.1 d4d5bce2da0d22b25485da3904f9f5fc11d7fcd4 (Debug, UBASAN)

      /test/11.7_dbg_san/sql/sql_plugin.cc:1274:17: runtime error: call to function wsrep_provider_plugin_deinit(void*) through pointer to incorrect function type 'int (*)(st_plugin_int *)'
      /test/11.7_dbg_san/sql/wsrep_plugin.cc:299: note: wsrep_provider_plugin_deinit(void*) defined here
          #0 0x5577fa1a9b4b in plugin_deinitialize(st_plugin_int*, bool) /test/11.7_dbg_san/sql/sql_plugin.cc:1274:17
          #1 0x5577fa19bb87 in reap_plugins() /test/11.7_dbg_san/sql/sql_plugin.cc:1345:5
          #2 0x5577fa1ab39a in plugin_shutdown() /test/11.7_dbg_san/sql/sql_plugin.cc:2086:7
          #3 0x5577f91a8572 in clean_up(bool) /test/11.7_dbg_san/sql/mysqld.cc:2006:3
          #4 0x5577f91a7761 in unireg_abort /test/11.7_dbg_san/sql/mysqld.cc:1928:3
          #5 0x5577f91b5434 in mysqld_main(int, char**) /test/11.7_dbg_san/sql/mysqld.cc:6106:7
          #6 0x5577f919f4a3 in main /test/11.7_dbg_san/sql/main.cc:34:10
          #7 0x145dfd82a1c9 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
          #8 0x145dfd82a28a in __libc_start_main csu/../csu/libc-start.c:360:3
          #9 0x5577f90c3c74 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/sql_plugin.cc:1274:17 
      

      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
      

      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.