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

The macro MYSQL_THDVAR_ULONG leads to undefined behaviour, calling mysql_sys_var_long

    XMLWordPrintable

Details

    Description

      Now that MDEV-26272 has been fixed and a cmake -DWITH_UBSAN=ON build with clang can pass the server bootstrap, we can find more undefined behaviour that is not flagged by GCC. Here is an example:

      10.4 832e96deb6f368591dcb35a4fa33b2fd770aa17a

      /mariadb/10.4/storage/innobase/handler/ha_innodb.cc:1821:9: runtime error: call to function mysql_sys_var_long(THD*, int) through pointer to incorrect function type 'unsigned long *(*)(THD *, int)'
      

      This is flagged for the function thd_lock_wait_timeout(), which simply accesses a data member that has been defined as follows:

      static MYSQL_THDVAR_ULONG(lock_wait_timeout, PLUGIN_VAR_RQCMDARG,
        "Timeout in seconds an InnoDB transaction may wait for a lock before being rolled back. Values above 100000000 disable the timeout.",
        NULL, NULL, 50, 0, 1024 * 1024 * 1024, 0);
      // ...
      static struct st_mysql_sys_var* innobase_system_variables[]= {
      // ...
        MYSQL_SYSVAR(lock_wait_timeout),
      // ...
        NULL
      };
      maria_declare_plugin(innobase)
      {
      // ...
      innobase_system_variables
      // ...
      },
      // ...
      maria_declare_plugin_end;
      

      Attachments

        Issue Links

          Activity

            People

              bnestere Brandon Nesterenko
              marko Marko Mäkelä
              Votes:
              0 Vote for this issue
              Watchers:
              3 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.