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

Various UBSAN function-type-mismatch errors when using MTR in maria_open, mi_open, _ma_open_datafile, mi_open_datafile and thr_multi_lock

    XMLWordPrintable

Details

    Description

      Create a test ./main/test.test with:

      SELECT 1;  # Unrelated query, to prevent MTR failing at startup
      

      And execute as:

      export UBSAN_OPTIONS=print_stacktrace=1:report_error_type=1; ./mtr test
      

      Leads to:

      CS 10.5.28 142851f1205d98270b917a98e1bdd483e1b8af0e (Debug, UBASAN)

      /test/10.5_dbg_san/storage/maria/ma_open.c:352:7: runtime error: call to function debug_sync(THD*, char const*, unsigned long) through pointer to incorrect function type 'void (*)(void *, const char *, unsigned long)'
      /test/10.5_dbg_san/sql/debug_sync.cc:1556: note: debug_sync(THD*, char const*, unsigned long) defined here
          #0 0x5631269c939c in maria_open /test/10.5_dbg_san/storage/maria/ma_open.c:352:7
          #1 0x563126834fab in ha_maria::open(char const*, int, unsigned int) /test/10.5_dbg_san/storage/maria/ha_maria.cc:1140:15
          #2 0x5631251959b2 in handler::ha_open(TABLE*, char const*, int, unsigned int, st_mem_root*, List<String>*) /test/10.5_dbg_san/sql/handler.cc:3100:7
          #3 0x563123c69baf in open_table_from_share(THD*, TABLE_SHARE*, st_mysql_const_lex_string const*, unsigned int, unsigned int, unsigned int, TABLE*, bool, List<String>*) /test/10.5_dbg_san/sql/table.cc:4325:33
          #4 0x5631229f7635 in open_table(THD*, TABLE_LIST*, Open_table_context*) /test/10.5_dbg_san/sql/sql_base.cc:2024:12
          #5 0x563122a24eb7 in open_and_process_table(THD*, TABLE_LIST*, unsigned int*, unsigned int, Prelocking_strategy*, bool, Open_table_context*) /test/10.5_dbg_san/sql/sql_base.cc:3819:14
          #6 0x563122a17759 in open_tables(THD*, DDL_options_st const&, TABLE_LIST**, unsigned int*, unsigned int, Prelocking_strategy*) /test/10.5_dbg_san/sql/sql_base.cc:4303:14
          #7 0x563122a4196a in open_and_lock_tables(THD*, DDL_options_st const&, TABLE_LIST*, bool, unsigned int, Prelocking_strategy*) /test/10.5_dbg_san/sql/sql_base.cc:5250:7
          #8 0x56312277cce6 in open_and_lock_tables(THD*, TABLE_LIST*, bool, unsigned int) /test/10.5_dbg_san/sql/sql_base.h:508:10
          #9 0x56312310d98f in plugin_load(st_mem_root*) /test/10.5_dbg_san/sql/sql_plugin.cc:1897:11
          #10 0x563123108e58 in plugin_init(int*, char**, int) /test/10.5_dbg_san/sql/sql_plugin.cc:1813:5
          #11 0x5631224b1233 in init_server_components() /test/10.5_dbg_san/sql/mysqld.cc:4998:7
          #12 0x5631224a54cc in mysqld_main(int, char**) /test/10.5_dbg_san/sql/mysqld.cc:5606:7
          #13 0x563122490983 in main /test/10.5_dbg_san/sql/main.cc:25:10
          #14 0x14829a22a1c9 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
          #15 0x14829a22a28a in __libc_start_main csu/../csu/libc-start.c:360:3
          #16 0x5631223b5154 in _start (/test/UBASAN_MD271124-mariadb-10.5.28-linux-x86_64-dbg/bin/mariadbd+0x3ed3154) (BuildId: 5aa7dce20f8daf2d280cf24110013248ddebc1ea)
       
      SUMMARY: UndefinedBehaviorSanitizer: function-type-mismatch /test/10.5_dbg_san/storage/maria/ma_open.c:352:7 
      

      CS 10.5.28 142851f1205d98270b917a98e1bdd483e1b8af0e (Debug, UBASAN)

      /test/10.5_dbg_san/storage/maria/ma_open.c:2057:3: runtime error: call to function debug_sync(THD*, char const*, unsigned long) through pointer to incorrect function type 'void (*)(void *, const char *, unsigned long)'
      /test/10.5_dbg_san/sql/debug_sync.cc:1556: note: debug_sync(THD*, char const*, unsigned long) defined here
          #0 0x5631269f5bc3 in _ma_open_datafile /test/10.5_dbg_san/storage/maria/ma_open.c:2057:3
          #1 0x5631269d95e3 in maria_open /test/10.5_dbg_san/storage/maria/ma_open.c:976:13
          #2 0x563126834fab in ha_maria::open(char const*, int, unsigned int) /test/10.5_dbg_san/storage/maria/ha_maria.cc:1140:15
          #3 0x5631251959b2 in handler::ha_open(TABLE*, char const*, int, unsigned int, st_mem_root*, List<String>*) /test/10.5_dbg_san/sql/handler.cc:3100:7
          #4 0x563123c69baf in open_table_from_share(THD*, TABLE_SHARE*, st_mysql_const_lex_string const*, unsigned int, unsigned int, unsigned int, TABLE*, bool, List<String>*) /test/10.5_dbg_san/sql/table.cc:4325:33
          #5 0x5631229f7635 in open_table(THD*, TABLE_LIST*, Open_table_context*) /test/10.5_dbg_san/sql/sql_base.cc:2024:12
          #6 0x563122a24eb7 in open_and_process_table(THD*, TABLE_LIST*, unsigned int*, unsigned int, Prelocking_strategy*, bool, Open_table_context*) /test/10.5_dbg_san/sql/sql_base.cc:3819:14
          #7 0x563122a17759 in open_tables(THD*, DDL_options_st const&, TABLE_LIST**, unsigned int*, unsigned int, Prelocking_strategy*) /test/10.5_dbg_san/sql/sql_base.cc:4303:14
          #8 0x563122a4196a in open_and_lock_tables(THD*, DDL_options_st const&, TABLE_LIST*, bool, unsigned int, Prelocking_strategy*) /test/10.5_dbg_san/sql/sql_base.cc:5250:7
          #9 0x56312277cce6 in open_and_lock_tables(THD*, TABLE_LIST*, bool, unsigned int) /test/10.5_dbg_san/sql/sql_base.h:508:10
          #10 0x56312310d98f in plugin_load(st_mem_root*) /test/10.5_dbg_san/sql/sql_plugin.cc:1897:11
          #11 0x563123108e58 in plugin_init(int*, char**, int) /test/10.5_dbg_san/sql/sql_plugin.cc:1813:5
          #12 0x5631224b1233 in init_server_components() /test/10.5_dbg_san/sql/mysqld.cc:4998:7
          #13 0x5631224a54cc in mysqld_main(int, char**) /test/10.5_dbg_san/sql/mysqld.cc:5606:7
          #14 0x563122490983 in main /test/10.5_dbg_san/sql/main.cc:25:10
          #15 0x14829a22a1c9 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
          #16 0x14829a22a28a in __libc_start_main csu/../csu/libc-start.c:360:3
          #17 0x5631223b5154 in _start (/test/UBASAN_MD271124-mariadb-10.5.28-linux-x86_64-dbg/bin/mariadbd+0x3ed3154) (BuildId: 5aa7dce20f8daf2d280cf24110013248ddebc1ea)
       
      SUMMARY: UndefinedBehaviorSanitizer: function-type-mismatch /test/10.5_dbg_san/storage/maria/ma_open.c:2057:3 
      

      CS 10.5.28 142851f1205d98270b917a98e1bdd483e1b8af0e (Debug, UBASAN)

      /test/10.5_dbg_san/mysys/thr_lock.c:1168:3: runtime error: call to function debug_sync(THD*, char const*, unsigned long) through pointer to incorrect function type 'void (*)(void *, const char *, unsigned long)'
      /test/10.5_dbg_san/sql/debug_sync.cc:1556: note: debug_sync(THD*, char const*, unsigned long) defined here
          #0 0x563128f1b567 in thr_multi_lock /test/10.5_dbg_san/mysys/thr_lock.c:1168:3
          #1 0x563125d793e5 in mysql_lock_tables(THD*, st_mysql_lock*, unsigned int) /test/10.5_dbg_san/sql/lock.cc:352:37
          #2 0x563125d70b8b in mysql_lock_tables(THD*, TABLE**, unsigned int, unsigned int) /test/10.5_dbg_san/sql/lock.cc:304:7
          #3 0x563122a3767e in lock_tables(THD*, TABLE_LIST*, unsigned int, unsigned int) /test/10.5_dbg_san/sql/sql_base.cc:5504:23
          #4 0x563122a41f80 in open_and_lock_tables(THD*, DDL_options_st const&, TABLE_LIST*, bool, unsigned int, Prelocking_strategy*) /test/10.5_dbg_san/sql/sql_base.cc:5259:7
          #5 0x56312277cce6 in open_and_lock_tables(THD*, TABLE_LIST*, bool, unsigned int) /test/10.5_dbg_san/sql/sql_base.h:508:10
          #6 0x56312310d98f in plugin_load(st_mem_root*) /test/10.5_dbg_san/sql/sql_plugin.cc:1897:11
          #7 0x563123108e58 in plugin_init(int*, char**, int) /test/10.5_dbg_san/sql/sql_plugin.cc:1813:5
          #8 0x5631224b1233 in init_server_components() /test/10.5_dbg_san/sql/mysqld.cc:4998:7
          #9 0x5631224a54cc in mysqld_main(int, char**) /test/10.5_dbg_san/sql/mysqld.cc:5606:7
          #10 0x563122490983 in main /test/10.5_dbg_san/sql/main.cc:25:10
          #11 0x14829a22a1c9 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
          #12 0x14829a22a28a in __libc_start_main csu/../csu/libc-start.c:360:3
          #13 0x5631223b5154 in _start (/test/UBASAN_MD271124-mariadb-10.5.28-linux-x86_64-dbg/bin/mariadbd+0x3ed3154) (BuildId: 5aa7dce20f8daf2d280cf24110013248ddebc1ea)
       
      SUMMARY: UndefinedBehaviorSanitizer: function-type-mismatch /test/10.5_dbg_san/mysys/thr_lock.c:1168:3 
      

      CS 10.5.28 142851f1205d98270b917a98e1bdd483e1b8af0e (Debug, UBASAN)

      /test/10.5_dbg_san/mysys/thr_lock.c:1185:3: runtime error: call to function debug_sync(THD*, char const*, unsigned long) through pointer to incorrect function type 'void (*)(void *, const char *, unsigned long)'
      /test/10.5_dbg_san/sql/debug_sync.cc:1556: note: debug_sync(THD*, char const*, unsigned long) defined here
          #0 0x563128f1b94d in thr_multi_lock /test/10.5_dbg_san/mysys/thr_lock.c:1185:3
          #1 0x563125d793e5 in mysql_lock_tables(THD*, st_mysql_lock*, unsigned int) /test/10.5_dbg_san/sql/lock.cc:352:37
          #2 0x563125d70b8b in mysql_lock_tables(THD*, TABLE**, unsigned int, unsigned int) /test/10.5_dbg_san/sql/lock.cc:304:7
          #3 0x563122a3767e in lock_tables(THD*, TABLE_LIST*, unsigned int, unsigned int) /test/10.5_dbg_san/sql/sql_base.cc:5504:23
          #4 0x563122a41f80 in open_and_lock_tables(THD*, DDL_options_st const&, TABLE_LIST*, bool, unsigned int, Prelocking_strategy*) /test/10.5_dbg_san/sql/sql_base.cc:5259:7
          #5 0x56312277cce6 in open_and_lock_tables(THD*, TABLE_LIST*, bool, unsigned int) /test/10.5_dbg_san/sql/sql_base.h:508:10
          #6 0x56312310d98f in plugin_load(st_mem_root*) /test/10.5_dbg_san/sql/sql_plugin.cc:1897:11
          #7 0x563123108e58 in plugin_init(int*, char**, int) /test/10.5_dbg_san/sql/sql_plugin.cc:1813:5
          #8 0x5631224b1233 in init_server_components() /test/10.5_dbg_san/sql/mysqld.cc:4998:7
          #9 0x5631224a54cc in mysqld_main(int, char**) /test/10.5_dbg_san/sql/mysqld.cc:5606:7
          #10 0x563122490983 in main /test/10.5_dbg_san/sql/main.cc:25:10
          #11 0x14829a22a1c9 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
          #12 0x14829a22a28a in __libc_start_main csu/../csu/libc-start.c:360:3
          #13 0x5631223b5154 in _start (/test/UBASAN_MD271124-mariadb-10.5.28-linux-x86_64-dbg/bin/mariadbd+0x3ed3154) (BuildId: 5aa7dce20f8daf2d280cf24110013248ddebc1ea)
       
      SUMMARY: UndefinedBehaviorSanitizer: function-type-mismatch /test/10.5_dbg_san/mysys/thr_lock.c:1185:3 
      

      Note that other unresolved UBSAN bugs from other tickets may also show besides these; only traces relevant to this ticket were left here. Note also that at the end of the log, some issues may repeat (after 'ready for connections'); check the top of the log to see all items listed here.

      Setup:

      Compiled with a recent version of Clang (I used Clang 18.1.3) with LLVM 18:
           # Note: 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 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
           sudo ln -s /usr/lib/llvm-17/lib/LLVMgold.so /usr/lib/llvm-18/lib/LLVMgold.so
      Compiled with: '-DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++' and:
          -DWITH_ASAN=ON -DWITH_ASAN_SCOPE=ON -DWITH_UBSAN=ON -DWSREP_LIB_WITH_ASAN=ON
      Set before execution:
          export UBSAN_OPTIONS=print_stacktrace=1:report_error_type=1
      

      Attachments

        Issue Links

          Activity

            People

              bnestere Brandon Nesterenko
              Roel Roel Van de Paar
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.