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

runtime error: call to function wsrep_plugin_init(void*) through pointer to incorrect function type

Details

    Description

      Now that MDEV-26272 was finally fixed, I thought that I would give clang-16 a try with cmake -DWITH_UBSAN=ON. One of the many errors (a function pointer type mismatch) would be fixed by the following:

      diff --git a/sql/wsrep_plugin.cc b/sql/wsrep_plugin.cc
      index 743b8a593b8..3fa5f7b7ef4 100644
      --- a/sql/wsrep_plugin.cc
      +++ b/sql/wsrep_plugin.cc
      @@ -18,18 +18,6 @@
       
       #include <mysql/plugin.h>
       
      -static int wsrep_plugin_init(void *p)
      -{
      -  WSREP_DEBUG("wsrep_plugin_init()");
      -  return 0;
      -}
      -
      -static int wsrep_plugin_deinit(void *p)
      -{
      -  WSREP_DEBUG("wsrep_plugin_deinit()");
      -  return 0;
      -}
      -
       struct Mysql_replication wsrep_plugin= {
         MYSQL_REPLICATION_INTERFACE_VERSION
       };
      @@ -42,8 +30,8 @@ maria_declare_plugin(wsrep)
         "Codership Oy",
         "Wsrep replication plugin",
         PLUGIN_LICENSE_GPL,
      -  wsrep_plugin_init,
      -  wsrep_plugin_deinit,
      +  NULL,
      +  NULL,
         0x0100,
         NULL, /* Status variables */
         NULL, /* System variables */
      

      Attachments

        Issue Links

          Activity

            I tested clang 15.0.7 as well, and it too is complaining about function pointer type mismatch. Here are two more examples:

            10.4 9695974e4b212aa4820e0ccfeb164f5444c0d58e

            /mariadb/10.4/sql/sql_show.cc:3843:7: runtime error: call to function wsrep_show_bf_aborts(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)'
            /mariadb/10.4/sql/sql_show.cc:3843:7: runtime error: call to function wsrep_show_ready(THD*, st_mysql_show_var*, char*) through pointer to incorrect function type 'int (*)(THD *, st_mysql_show_var *, void *, system_status_var *, enum_var_type)'
            

            Because the mismatching parameters are at the end of the functions and unused, this may not result in an actual bug, depending on the ABI. For example, in the System-V AMD64 ABI, the first 6 function parameters would be passed in registers. It should not matter if the callee is ignoring some of these registers.

            marko Marko Mäkelä added a comment - I tested clang 15.0.7 as well, and it too is complaining about function pointer type mismatch. Here are two more examples: 10.4 9695974e4b212aa4820e0ccfeb164f5444c0d58e /mariadb/10.4/sql/sql_show.cc:3843:7: runtime error: call to function wsrep_show_bf_aborts(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)' /mariadb/10.4/sql/sql_show.cc:3843:7: runtime error: call to function wsrep_show_ready(THD*, st_mysql_show_var*, char*) through pointer to incorrect function type 'int (*)(THD *, st_mysql_show_var *, void *, system_status_var *, enum_var_type)' Because the mismatching parameters are at the end of the functions and unused, this may not result in an actual bug, depending on the ABI. For example, in the System-V AMD64 ABI , the first 6 function parameters would be passed in registers. It should not matter if the callee is ignoring some of these registers.

            I tested my fix with the following patch so that mtr would not flag test failures due to other cmake -DWITH_UBSAN=ON issues:

            index cdd8f0bf6cd..7df05378f0a 100755
            --- a/mysql-test/mysql-test-run.pl
            +++ b/mysql-test/mysql-test-run.pl
            @@ -4370,8 +4370,8 @@ sub extract_warning_lines ($$) {
                  qr/missing DBUG_RETURN/,
                  qr/Attempting backtrace/,
                  qr/Assertion .* failed/,
            -     qr/Sanitizer/,
            -     qr/runtime error:/,
            +     qr/(Address|Leak)Sanitizer/,
            +#     qr/runtime error:/,
                 );
               # These are taken from the include/mtr_warnings.sql global suppression
               # list. They occur delayed, so they can be parsed during shutdown rather
            

            and the following test invocation:

            ./mtr --parallel=40 --big-test --force --suite=galera,galera_3nodes,galera_sr,galera_3nodes_sr
            grep 'runtime error.*function wsrep' var/*/log/mysqld*err*
            

            The grep command returned an empty result. There were incorrect calls to some functions (see MDEV-33158), but not to ones whose name would start with wsrep.

            marko Marko Mäkelä added a comment - I tested my fix with the following patch so that mtr would not flag test failures due to other cmake -DWITH_UBSAN=ON issues: index cdd8f0bf6cd..7df05378f0a 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -4370,8 +4370,8 @@ sub extract_warning_lines ($$) { qr/missing DBUG_RETURN/, qr/Attempting backtrace/, qr/Assertion .* failed/, - qr/Sanitizer/, - qr/runtime error:/, + qr/(Address|Leak)Sanitizer/, +# qr/runtime error:/, ); # These are taken from the include/mtr_warnings.sql global suppression # list. They occur delayed, so they can be parsed during shutdown rather and the following test invocation: ./mtr --parallel=40 --big-test --force --suite=galera,galera_3nodes,galera_sr,galera_3nodes_sr grep 'runtime error.*function wsrep' var/*/log/mysqld*err* The grep command returned an empty result. There were incorrect calls to some functions (see MDEV-33158 ), but not to ones whose name would start with wsrep .

            People

              marko Marko Mäkelä
              marko Marko Mäkelä
              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.