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

runtime error: call to function show_cached_thread_count()/show_binlog_space_total() through pointer to incorrect function type

Details

    Description

      SELECT * FROM information_schema.global_status;
      

      Leads to:

      CS 10.5.28 142851f1205d98270b917a98e1bdd483e1b8af0e (Debug, UBASAN, Clang)

      /test/10.5_dbg_san/sql/sql_show.cc:3791:7: runtime error: call to function show_cached_thread_count(THD*, st_mysql_show_var*, char*, enum_var_type) through pointer to incorrect function type 'int (*)(THD *, st_mysql_show_var *, void *, system_status_var *, enum_var_type)'
      /test/10.5_dbg_san/sql/mysqld.cc:7394: note: show_cached_thread_count(THD*, st_mysql_show_var*, char*, enum_var_type) defined here
          #0 0x55bf73cd89d0 in show_status_array(THD*, char const*, st_mysql_show_var*, enum_var_type, system_status_var*, char const*, TABLE*, bool, Item*) /test/10.5_dbg_san/sql/sql_show.cc:3791:7
          #1 0x55bf73cdd9b9 in fill_status(THD*, TABLE_LIST*, Item*) /test/10.5_dbg_san/sql/sql_show.cc:8131:8
          #2 0x55bf73cf837a in get_schema_tables_result(JOIN*, enum_schema_table_state) /test/10.5_dbg_san/sql/sql_show.cc:9011:11
          #3 0x55bf73973be9 in JOIN::exec_inner() /test/10.5_dbg_san/sql/sql_select.cc:4618:7
          #4 0x55bf7396d8d1 in JOIN::exec() /test/10.5_dbg_san/sql/sql_select.cc:4441:3
          #5 0x55bf7381c543 in mysql_select(THD*, TABLE_LIST*, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*) /test/10.5_dbg_san/sql/sql_select.cc:4918:9
          #6 0x55bf738180c7 in handle_select(THD*, LEX*, select_result*, unsigned long) /test/10.5_dbg_san/sql/sql_select.cc:449:10
          #7 0x55bf735f43f0 in execute_sqlcom_select(THD*, TABLE_LIST*) /test/10.5_dbg_san/sql/sql_parse.cc:6437:12
          #8 0x55bf7358859f in mysql_execute_command(THD*) /test/10.5_dbg_san/sql/sql_parse.cc:4029:12
          #9 0x55bf7352f4e3 in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /test/10.5_dbg_san/sql/sql_parse.cc:8237:18
          #10 0x55bf7350f453 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /test/10.5_dbg_san/sql/sql_parse.cc:1891:7
          #11 0x55bf73537a19 in do_command(THD*) /test/10.5_dbg_san/sql/sql_parse.cc:1375:17
          #12 0x55bf744b1f30 in do_handle_one_connection(CONNECT*, bool) /test/10.5_dbg_san/sql/sql_connect.cc:1386:11
          #13 0x55bf744b06fd in handle_one_connection /test/10.5_dbg_san/sql/sql_connect.cc:1298:5
          #14 0x55bf729aba8c in asan_thread_start(void*) asan_interceptors.cpp.o
          #15 0x1545ee09ca93 in start_thread nptl/pthread_create.c:447:8
          #16 0x1545ee129c3b in clone3 misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
       
      SUMMARY: UndefinedBehaviorSanitizer: function-type-mismatch /test/10.5_dbg_san/sql/sql_show.cc:3791:7 
      

      Setup:

      Compiled with a recent version of Clang (I used Clang 18.1.3) with LLVM 18:
      # 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
          -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
      

      Bug confirmed present in:
      MariaDB: 10.5.28 (dbg), 10.5.28 (opt), 10.6.21 (dbg), 10.6.21 (opt), 10.11.11 (dbg), 10.11.11 (opt), 11.4.5 (dbg), 11.4.5 (opt), 11.7.1 (dbg), 11.7.1 (opt), 11.8.0 (dbg), 11.8.0 (opt)

      Attachments

        Issue Links

          Activity

            Note that for 11.4+ the call to function differs:

            CS 11.4.5 2719cc4925c032f483edb0e61c0f487e0c429ae6 (Optimized, UBASAN, Clang)

            /test/11.4_opt_san/sql/sql_show.cc:3905:7: runtime error: call to function show_binlog_space_total(THD*, st_mysql_show_var*, char*, system_status_var*, enum_var_type) through pointer to incorrect function type 'int (*)(THD *, st_mysql_show_var *, void *, system_status_var *, enum_var_type)'
            /test/11.4_opt_san/sql/mysqld.cc:7365: note: show_binlog_space_total(THD*, st_mysql_show_var*, char*, system_status_var*, enum_var_type) defined here
                #0 0x563c560d2636 in show_status_array(THD*, char const*, st_mysql_show_var*, enum_var_type, system_status_var*, char const*, TABLE*, bool, Item*) /test/11.4_opt_san/sql/sql_show.cc:3905:7
                #1 0x563c560d4dc7 in fill_status(THD*, TABLE_LIST*, Item*) /test/11.4_opt_san/sql/sql_show.cc:8543:8
                #2 0x563c560e07b1 in get_schema_tables_result(JOIN*, enum_schema_table_state) /test/11.4_opt_san/sql/sql_show.cc:9412:11
                #3 0x563c55f0d1eb in JOIN::exec_inner() /test/11.4_opt_san/sql/sql_select.cc:5006:7
                #4 0x563c55f0b621 in JOIN::exec() /test/11.4_opt_san/sql/sql_select.cc:4828:8
                #5 0x563c55e68927 in mysql_select(THD*, TABLE_LIST*, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*) /test/11.4_opt_san/sql/sql_select.cc:5358:21
                #6 0x563c55e6677d in handle_select(THD*, LEX*, select_result*, unsigned long long) /test/11.4_opt_san/sql/sql_select.cc:642:10
                #7 0x563c55d19a4c in execute_sqlcom_select(THD*, TABLE_LIST*) /test/11.4_opt_san/sql/sql_parse.cc:6169:12
                #8 0x563c55d0323f in mysql_execute_command(THD*, bool) /test/11.4_opt_san/sql/sql_parse.cc:3962:12
                #9 0x563c55cc87e2 in mysql_parse(THD*, char*, unsigned int, Parser_state*) /test/11.4_opt_san/sql/sql_parse.cc:7893:18
                #10 0x563c55cbd668 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool) /test/11.4_opt_san/sql/sql_parse.cc:1905:7
                #11 0x563c55ccb5be in do_command(THD*, bool) /test/11.4_opt_san/sql/sql_parse.cc:1418:17
                #12 0x563c5649e9a8 in do_handle_one_connection(CONNECT*, bool) /test/11.4_opt_san/sql/sql_connect.cc:1408:11
                #13 0x563c5649ddf4 in handle_one_connection /test/11.4_opt_san/sql/sql_connect.cc:1320:5
                #14 0x563c55601bdc in asan_thread_start(void*) asan_interceptors.cpp.o
                #15 0x148b3449ca93 in start_thread nptl/pthread_create.c:447:8
                #16 0x148b34529c3b in clone3 misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
             
            SUMMARY: UndefinedBehaviorSanitizer: function-type-mismatch /test/11.4_opt_san/sql/sql_show.cc:3905:7
            

            Roel Roel Van de Paar added a comment - Note that for 11.4+ the call to function differs: CS 11.4.5 2719cc4925c032f483edb0e61c0f487e0c429ae6 (Optimized, UBASAN, Clang) /test/11.4_opt_san/sql/sql_show.cc:3905:7: runtime error: call to function show_binlog_space_total(THD*, st_mysql_show_var*, char*, system_status_var*, enum_var_type) through pointer to incorrect function type 'int (*)(THD *, st_mysql_show_var *, void *, system_status_var *, enum_var_type)' /test/11.4_opt_san/sql/mysqld.cc:7365: note: show_binlog_space_total(THD*, st_mysql_show_var*, char*, system_status_var*, enum_var_type) defined here #0 0x563c560d2636 in show_status_array(THD*, char const*, st_mysql_show_var*, enum_var_type, system_status_var*, char const*, TABLE*, bool, Item*) /test/11.4_opt_san/sql/sql_show.cc:3905:7 #1 0x563c560d4dc7 in fill_status(THD*, TABLE_LIST*, Item*) /test/11.4_opt_san/sql/sql_show.cc:8543:8 #2 0x563c560e07b1 in get_schema_tables_result(JOIN*, enum_schema_table_state) /test/11.4_opt_san/sql/sql_show.cc:9412:11 #3 0x563c55f0d1eb in JOIN::exec_inner() /test/11.4_opt_san/sql/sql_select.cc:5006:7 #4 0x563c55f0b621 in JOIN::exec() /test/11.4_opt_san/sql/sql_select.cc:4828:8 #5 0x563c55e68927 in mysql_select(THD*, TABLE_LIST*, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*) /test/11.4_opt_san/sql/sql_select.cc:5358:21 #6 0x563c55e6677d in handle_select(THD*, LEX*, select_result*, unsigned long long) /test/11.4_opt_san/sql/sql_select.cc:642:10 #7 0x563c55d19a4c in execute_sqlcom_select(THD*, TABLE_LIST*) /test/11.4_opt_san/sql/sql_parse.cc:6169:12 #8 0x563c55d0323f in mysql_execute_command(THD*, bool) /test/11.4_opt_san/sql/sql_parse.cc:3962:12 #9 0x563c55cc87e2 in mysql_parse(THD*, char*, unsigned int, Parser_state*) /test/11.4_opt_san/sql/sql_parse.cc:7893:18 #10 0x563c55cbd668 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool) /test/11.4_opt_san/sql/sql_parse.cc:1905:7 #11 0x563c55ccb5be in do_command(THD*, bool) /test/11.4_opt_san/sql/sql_parse.cc:1418:17 #12 0x563c5649e9a8 in do_handle_one_connection(CONNECT*, bool) /test/11.4_opt_san/sql/sql_connect.cc:1408:11 #13 0x563c5649ddf4 in handle_one_connection /test/11.4_opt_san/sql/sql_connect.cc:1320:5 #14 0x563c55601bdc in asan_thread_start(void*) asan_interceptors.cpp.o #15 0x148b3449ca93 in start_thread nptl/pthread_create.c:447:8 #16 0x148b34529c3b in clone3 misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78   SUMMARY: UndefinedBehaviorSanitizer: function-type-mismatch /test/11.4_opt_san/sql/sql_show.cc:3905:7

            A UBSAN suppresion filter function:show_status_array was added for this bug. Any issue with show_status_array anywhere in the stack will be filtered. This is a limitation of UBSAN suppression filtering. The filter will be removed once the bug is fixed.

            Roel Roel Van de Paar added a comment - A UBSAN suppresion filter function:show_status_array was added for this bug. Any issue with show_status_array anywhere in the stack will be filtered. This is a limitation of UBSAN suppression filtering. The filter will be removed once the bug is fixed.
            danblack Daniel Black added a comment -

            bnestere can I get a review on these two PRs that correct this please:

            danblack Daniel Black added a comment - bnestere can I get a review on these two PRs that correct this please: https://github.com/MariaDB/server/pull/3737 https://github.com/MariaDB/server/pull/3738

            Thanks danblack, looks good.

            bnestere Brandon Nesterenko added a comment - Thanks danblack , looks good.

            Thank you very much danblack and bnestere for the help, fix and speedy resolution.

            Roel Roel Van de Paar added a comment - Thank you very much danblack and bnestere for the help, fix and speedy resolution.

            People

              danblack Daniel Black
              Roel Roel Van de Paar
              Votes:
              0 Vote for this issue
              Watchers:
              3 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.