[MDEV-26852] Spider: -Werror=maybe-uninitialized raises on spd_sys_table.cc and ha_spider.cc Created: 2021-10-18  Updated: 2022-09-26  Resolved: 2022-09-26

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - Spider
Affects Version/s: 10.2, 10.3, 10.4, 10.5, 10.6
Fix Version/s: 10.3.37, 10.4.27, 10.5.18, 10.6.11, 10.7.7, 10.8.6, 10.9.4, 10.10.2, 10.11.0

Type: Bug Priority: Major
Reporter: Nayuta Yanagisawa (Inactive) Assignee: Nayuta Yanagisawa (Inactive)
Resolution: Fixed Votes: 0
Labels: None


 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;



 Comments   
Comment by Nayuta Yanagisawa (Inactive) [ 2021-10-18 ]

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);

Comment by Nayuta Yanagisawa (Inactive) [ 2021-10-19 ]

holyfoot Please review: https://github.com/MariaDB/server/commit/0aee34bb3cf2de502304b7694a5b2b785fe30338

Comment by Nayuta Yanagisawa (Inactive) [ 2021-12-24 ]

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

Comment by Nayuta Yanagisawa (Inactive) [ 2022-09-26 ]

https://github.com/MariaDB/server/commit/fb60f5e7d9e2006986b4c89a4c3d877dab35cfc9

Comment by Alexey Botchkov [ 2022-09-26 ]

Ok, i'm fine with this patch
https://github.com/MariaDB/server/commit/0aee34bb3cf2de502304b7694a5b2b785fe30338

Comment by Nayuta Yanagisawa (Inactive) [ 2022-09-26 ]

OK. Thank you for the review.

Comment by Nayuta Yanagisawa (Inactive) [ 2022-09-26 ]

The patch for 10.5+ for the conflict resolution: https://github.com/MariaDB/server/commit/b83da40b9a5dfc5a76cdb21a3261261e9cbde4fe (cc: marko)

Generated at Thu Feb 08 09:48:27 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.