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

Spider: -Werror=maybe-uninitialized raises on spd_sys_table.cc and ha_spider.cc

Details

    Description

      When compiling Spider with 10.6, I got these errors:

      /mariadb/10.6m/storage/spider/spd_sys_table.cc: In function 'int spider_get_sys_link_mon_key(TABLE*, SPIDER_MON_KEY*, MEM_ROOT*, int*)':
      /mariadb/10.6m/storage/spider/spd_sys_table.cc:3110:12: error: 'link_id' may be used uninitialized in this function [-Werror=maybe-uninitialized]
       3110 |     !memcmp(link_id, mon_key->link_id, link_id_length)
            |      ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      /mariadb/10.6m/storage/spider/spd_sys_table.cc:3109:12: error: 'table_name' may be used uninitialized in this function [-Werror=maybe-uninitialized]
       3109 |     !memcmp(table_name, mon_key->table_name, table_name_length) &&
            |      ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      

      That is with GCC 11, CMAKE_BUILD_TYPE=Debug and CMAKE_CXX_FLAGS=-Og.

      On 10.3, I got the following:

      /home/nayuta_mariadb/repo/mariadb-server/storage/spider/ha_spider.cc:428:47: error: ‘hash_value’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
        428 |     partition_handler_share->table_hash_value = hash_value;
      

      Attachments

        Activity

          A possible fix proposed by marko is the following:

          diff --git a/storage/spider/spd_sys_table.cc b/storage/spider/spd_sys_table.cc
          index 69e4d259296..67f1eabaa8d 100644
          --- a/storage/spider/spd_sys_table.cc
          +++ b/storage/spider/spd_sys_table.cc
          @@ -3076,14 +3076,14 @@ int spider_get_sys_link_mon_key(
               DBUG_RETURN(ER_SPIDER_SYS_TABLE_VERSION_NUM);
             }
           
          -  if (
          -    !(db_name = get_field(mem_root,
          -      table->field[SPIDER_LINK_MON_SERVERS_DB_NAME_POS])) ||
          -    !(table_name = get_field(mem_root,
          -      table->field[SPIDER_LINK_MON_SERVERS_TABLE_NAME_POS])) ||
          -    !(link_id = get_field(mem_root,
          -      table->field[SPIDER_LINK_MON_SERVERS_LINK_ID_POS]))
          -  )
          +  if (!(db_name = get_field(mem_root, table->field
          +                            [SPIDER_LINK_MON_SERVERS_DB_NAME_POS])))
          +    DBUG_RETURN(HA_ERR_OUT_OF_MEM);
          +  if (!(table_name = get_field(mem_root, table->field
          +                               [SPIDER_LINK_MON_SERVERS_TABLE_NAME_POS])))
          +    DBUG_RETURN(HA_ERR_OUT_OF_MEM);
          +  if (!(link_id = get_field(mem_root, table->field
          +                            [SPIDER_LINK_MON_SERVERS_LINK_ID_POS])))
               DBUG_RETURN(HA_ERR_OUT_OF_MEM);
           
             db_name_length = strlen(db_name);
          

          nayuta-yanagisawa Nayuta Yanagisawa (Inactive) added a comment - A possible fix proposed by marko is the following: diff --git a/storage/spider/spd_sys_table.cc b/storage/spider/spd_sys_table.cc index 69e4d259296..67f1eabaa8d 100644 --- a/storage/spider/spd_sys_table.cc +++ b/storage/spider/spd_sys_table.cc @@ -3076,14 +3076,14 @@ int spider_get_sys_link_mon_key( DBUG_RETURN(ER_SPIDER_SYS_TABLE_VERSION_NUM); } - if ( - !(db_name = get_field(mem_root, - table->field[SPIDER_LINK_MON_SERVERS_DB_NAME_POS])) || - !(table_name = get_field(mem_root, - table->field[SPIDER_LINK_MON_SERVERS_TABLE_NAME_POS])) || - !(link_id = get_field(mem_root, - table->field[SPIDER_LINK_MON_SERVERS_LINK_ID_POS])) - ) + if (!(db_name = get_field(mem_root, table->field + [SPIDER_LINK_MON_SERVERS_DB_NAME_POS]))) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + if (!(table_name = get_field(mem_root, table->field + [SPIDER_LINK_MON_SERVERS_TABLE_NAME_POS]))) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + if (!(link_id = get_field(mem_root, table->field + [SPIDER_LINK_MON_SERVERS_LINK_ID_POS]))) DBUG_RETURN(HA_ERR_OUT_OF_MEM); db_name_length = strlen (db_name);
          nayuta-yanagisawa Nayuta Yanagisawa (Inactive) added a comment - - edited holyfoot Please review: https://github.com/MariaDB/server/commit/0aee34bb3cf2de502304b7694a5b2b785fe30338

          holyfoot Please check the last comments by marko and me. What do you think?

          nayuta-yanagisawa Nayuta Yanagisawa (Inactive) added a comment - holyfoot Please check the last comments by marko and me. What do you think?
          nayuta-yanagisawa Nayuta Yanagisawa (Inactive) added a comment - https://github.com/MariaDB/server/commit/fb60f5e7d9e2006986b4c89a4c3d877dab35cfc9
          holyfoot Alexey Botchkov added a comment - Ok, i'm fine with this patch https://github.com/MariaDB/server/commit/0aee34bb3cf2de502304b7694a5b2b785fe30338

          OK. Thank you for the review.

          nayuta-yanagisawa Nayuta Yanagisawa (Inactive) added a comment - OK. Thank you for the review.
          nayuta-yanagisawa Nayuta Yanagisawa (Inactive) added a comment - The patch for 10.5+ for the conflict resolution: https://github.com/MariaDB/server/commit/b83da40b9a5dfc5a76cdb21a3261261e9cbde4fe (cc: marko )

          People

            nayuta-yanagisawa Nayuta Yanagisawa (Inactive)
            nayuta-yanagisawa Nayuta Yanagisawa (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 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.