Reported by marko, happens when building with -Og and in various components, and likely to pop up again from time to time, so I suggest we keep this ticket open and ongoing as more patches get reviewed and pushed for this issue.
The warnings are issued by GCC when building with -Og (optimize while trying to keep the executable debugger-friendly).
Marko Mäkelä
added a comment - The warnings are issued by GCC when building with -Og (optimize while trying to keep the executable debugger-friendly).
Yuchen Pei
added a comment - - edited Hi marko , ptal thanks (based on 10.5 and fixing at sql layer / innodb)
bb-10.5-mdev-33220 ef39e155244bbe01da6762005ecf441303a7ef54
MDEV-33220 Fix -Wmaybe-uninitialized warnings
It's a technical task to fix compiler complaints when run with a specific flag. It is likely to be a recurring issue across different versions because people don't always compile with -Og and gcc 13 when the problem would resurface.
> Fixing build errors should be a bug, not a task.
While I agree in general build errors should be bugs, this ticket is about making the code compile when the compiler is run with a specific flag and specific compiler versions, and the complaints are all false positives. So I think it's more a technical task than bug. Also it will resurface from time to time as people don't always compile under these conditions.
Yuchen Pei
added a comment - - edited > Is this task really for 10.5 or for 11.5?
It's a technical task to fix compiler complaints when run with a specific flag. It is likely to be a recurring issue across different versions because people don't always compile with -Og and gcc 13 when the problem would resurface.
> Fixing build errors should be a bug, not a task.
While I agree in general build errors should be bugs, this ticket is about making the code compile when the compiler is run with a specific flag and specific compiler versions, and the complaints are all false positives. So I think it's more a technical task than bug. Also it will resurface from time to time as people don't always compile under these conditions.
Yuchen Pei
added a comment - - edited Got some time to try again today. Here's a 10.4 patch
8c78ebdb574 upstream/bb-10.4-mdev-33220 MDEV-33220 Fix -wmaybe-uninitialized warnings
There's probably gonna be conflicts or insufficient changes that leave more warnings when merged to higher versions.
For other versions:
a547bfb9ef7 upstream/bb-10.5-mdev-33220 MDEV-33220 Fix -wmaybe-uninitialized warnings
I think that we should make use of an additional goto label oom: in order to avoid duplicated function calls. I see that this particular function is duplicating a lot of such calls already. Last time I checked, even at -O3 such calls are not being optimized away.
Also, it may be a matter of taste, but I would put the assignment outside the if condition. It should make no difference to the generated code: the value should be cached in the "function return value" register (rax on AMD64).
Marko Mäkelä
added a comment - Thank you, this does fix the -Wmaybe-uninitialized warnings for me. However, I notice some added code duplication, like the following:
diff --git a/storage/spider/spd_copy_tables.cc b/storage/spider/spd_copy_tables.cc
index 6e9d1f2bcc6..dbe74ddaa8d 100644
--- a/storage/spider/spd_copy_tables.cc
+++ b/storage/spider/spd_copy_tables.cc
@@ -1002,7 +1002,12 @@ long long spider_copy_tables_body(
all_link_cnt =
copy_tables->link_idx_count[0] + copy_tables->link_idx_count[1];
if (
- !(tmp_sql = new spider_string[all_link_cnt]) ||
+ !(tmp_sql = new spider_string[all_link_cnt])
+ ) {
+ my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM);
+ goto error;
+ }
+ if (
!(spider = new ha_spider[all_link_cnt])
) {
my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM);
I think that we should make use of an additional goto label oom: in order to avoid duplicated function calls. I see that this particular function is duplicating a lot of such calls already. Last time I checked, even at -O3 such calls are not being optimized away.
Also, it may be a matter of taste, but I would put the assignment outside the if condition. It should make no difference to the generated code: the value should be cached in the "function return value" register ( rax on AMD64).
A side finding in the above code snippet is that if we failed to allocate spider, then we would fail to free the memory that was allocated for tmp_sql.
Marko Mäkelä
added a comment - A side finding in the above code snippet is that if we failed to allocate spider , then we would fail to free the memory that was allocated for tmp_sql .
> I think that we should make use of an additional goto label oom: in order to avoid duplicated function calls. I see that this particular function is duplicating a lot of such calls already. Last time I checked, even at -O3 such calls are not being optimized away.
Done.
> Also, it may be a matter of taste, but I would put the assignment outside the if condition. It should make no difference to the generated code: the value should be cached in the "function return value" register (rax on AMD64).
Ack. I prefer the assignment in the condition because it is shorter.
> A side finding in the above code snippet is that if we failed to allocate spider, then we would fail to free the memory that was allocated for tmp_sql.
This is prevented by the following lines under the error label:
if (tmp_sql)
{
delete [] tmp_sql;
}
Yuchen Pei
added a comment - Thanks for the comments. ptal at the updated patch:
b1fe542c59b upstream/bb-10.4-mdev-33220 MDEV-33220 Fix -wmaybe-uninitialized warnings
> I think that we should make use of an additional goto label oom: in order to avoid duplicated function calls. I see that this particular function is duplicating a lot of such calls already. Last time I checked, even at -O3 such calls are not being optimized away.
Done.
> Also, it may be a matter of taste, but I would put the assignment outside the if condition. It should make no difference to the generated code: the value should be cached in the "function return value" register ( rax on AMD64).
Ack. I prefer the assignment in the condition because it is shorter.
> A side finding in the above code snippet is that if we failed to allocate spider , then we would fail to free the memory that was allocated for tmp_sql .
This is prevented by the following lines under the error label:
if (tmp_sql)
{
delete [] tmp_sql;
}
Thank you, the fixes look good, but I think that we should be more specific that this is about fixing g++-13 -Wmaybe-uninitialized. I tried compiling the 10.4 branch with GCC 14.0.1, using both -Og and -O3. No warnings were issued before or after your changes. I also tried compiling with GCC 13.2.0. Your fixes make a difference for both settings.
Some other warnings were issued, and I took the liberty of fixing them.
I would like to point out that just free(NULL) is a valid operation in C, also in C++ it is redundant to check if a pointer is null before invoking delete. Fixing the memory leaks is the subject of another task.
Marko Mäkelä
added a comment - Thank you, the fixes look good, but I think that we should be more specific that this is about fixing g++-13 -Wmaybe-uninitialized . I tried compiling the 10.4 branch with GCC 14.0.1, using both -Og and -O3 . No warnings were issued before or after your changes. I also tried compiling with GCC 13.2.0. Your fixes make a difference for both settings.
Some other warnings were issued, and I took the liberty of fixing them.
I would like to point out that just free(NULL) is a valid operation in C, also in C++ it is redundant to check if a pointer is null before invoking delete . Fixing the memory leaks is the subject of another task.
MDEV-33220 Fix -wmaybe-uninitialized warnings for g++-13
Yuchen Pei
added a comment - Thanks marko , I've updated the commit message and the delete [] to be unconditional. ptal thanks
bb-10.4-ycp bb-10.4-mdev-33220 42439ff66ab75249f56eee70db5f83329ff21393
MDEV-33220 Fix -wmaybe-uninitialized warnings for g++-13
Thank you, I tested that branch merged on the current 10.4 head, using GCC 13.2.0, and there were no -Wmaybe-uninitialized warnings.
At -O3 (not -Og or -O2) there were some -Warray-bounds, but that is a separate matter.
Marko Mäkelä
added a comment - Thank you, I tested that branch merged on the current 10.4 head, using GCC 13.2.0, and there were no -Wmaybe-uninitialized warnings.
At -O3 (not -Og or -O2 ) there were some -Warray-bounds , but that is a separate matter.
Pushed ef9cdacf51320fbb2935c03d406b22a3688bf295 to 10.4
Other versions with conflicts:
10.5 733ec188d1e982fbdbf9925ac65a5bfb4ea6bc6a
10.11 58971b7e1ba4711f8f25d7264310427154317eeb
no non-trivial conflict resolutions, so higher versions should be similarly easily resolved.
Yuchen Pei
added a comment - - edited Thanks for the review.
Pushed ef9cdacf51320fbb2935c03d406b22a3688bf295 to 10.4
Other versions with conflicts:
10.5 733ec188d1e982fbdbf9925ac65a5bfb4ea6bc6a
10.11 58971b7e1ba4711f8f25d7264310427154317eeb
no non-trivial conflict resolutions, so higher versions should be similarly easily resolved.
People
Yuchen Pei
Yuchen Pei
Votes:
0Vote for this issue
Watchers:
3Start 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.
{"report":{"fcp":982.9000000059605,"ttfb":214.59999999403954,"pageVisibility":"visible","entityId":127226,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"49499ed7-5654-4f6f-a071-618ed01642bd","navigationType":0,"readyForUser":1057.5999999940395,"redirectCount":0,"resourceLoadedEnd":1030.5,"resourceLoadedStart":222.19999998807907,"resourceTiming":[{"duration":121.90000000596046,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":222.19999998807907,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":222.19999998807907,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":344.09999999403954,"responseStart":0,"secureConnectionStart":0},{"duration":122.09999999403954,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2cib/820016/12ta74/494e4c556ecbb29f90a3d3b4f09cb99c/_/download/contextbatch/css/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true&whisper-enabled=true","startTime":222.40000000596046,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":222.40000000596046,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":344.5,"responseStart":0,"secureConnectionStart":0},{"duration":189,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":222.59999999403954,"connectEnd":222.59999999403954,"connectStart":222.59999999403954,"domainLookupEnd":222.59999999403954,"domainLookupStart":222.59999999403954,"fetchStart":222.59999999403954,"redirectEnd":0,"redirectStart":0,"requestStart":347.19999998807907,"responseEnd":411.59999999403954,"responseStart":379.19999998807907,"secureConnectionStart":222.59999999403954},{"duration":461,"initiatorType":"script","name":"https://jira.mariadb.org/s/2d8175ec2fa4c816e8023260bd8c1786-CDN/lu2cib/820016/12ta74/494e4c556ecbb29f90a3d3b4f09cb99c/_/download/contextbatch/js/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true&whisper-enabled=true","startTime":222.69999998807907,"connectEnd":222.69999998807907,"connectStart":222.69999998807907,"domainLookupEnd":222.69999998807907,"domainLookupStart":222.69999998807907,"fetchStart":222.69999998807907,"redirectEnd":0,"redirectStart":0,"requestStart":626.5999999940395,"responseEnd":683.6999999880791,"responseStart":640.7999999821186,"secureConnectionStart":222.69999998807907},{"duration":419.39999997615814,"initiatorType":"script","name":"https://jira.mariadb.org/s/a9324d6758d385eb45c462685ad88f1d-CDN/lu2cib/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":222.90000000596046,"connectEnd":222.90000000596046,"connectStart":222.90000000596046,"domainLookupEnd":222.90000000596046,"domainLookupStart":222.90000000596046,"fetchStart":222.90000000596046,"redirectEnd":0,"redirectStart":0,"requestStart":627.2999999821186,"responseEnd":642.2999999821186,"responseStart":641.4000000059605,"secureConnectionStart":222.90000000596046},{"duration":420.5,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":223.09999999403954,"connectEnd":223.09999999403954,"connectStart":223.09999999403954,"domainLookupEnd":223.09999999403954,"domainLookupStart":223.09999999403954,"fetchStart":223.09999999403954,"redirectEnd":0,"redirectStart":0,"requestStart":629.2999999821186,"responseEnd":643.5999999940395,"responseStart":643.0999999940395,"secureConnectionStart":223.09999999403954},{"duration":429.10000002384186,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":223.2999999821186,"connectEnd":223.2999999821186,"connectStart":223.2999999821186,"domainLookupEnd":223.2999999821186,"domainLookupStart":223.2999999821186,"fetchStart":223.2999999821186,"redirectEnd":0,"redirectStart":0,"requestStart":640.4000000059605,"responseEnd":652.4000000059605,"responseStart":651.7999999821186,"secureConnectionStart":223.2999999821186},{"duration":414.09999999403954,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2cib/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":223.59999999403954,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":223.59999999403954,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":637.6999999880791,"responseStart":0,"secureConnectionStart":0},{"duration":473.5,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":223.69999998807907,"connectEnd":223.69999998807907,"connectStart":223.69999998807907,"domainLookupEnd":223.69999998807907,"domainLookupStart":223.69999998807907,"fetchStart":223.69999998807907,"redirectEnd":0,"redirectStart":0,"requestStart":662.5999999940395,"responseEnd":697.1999999880791,"responseStart":696.2999999821186,"secureConnectionStart":223.69999998807907},{"duration":430.60000002384186,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2cib/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/css/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.css?jira.create.linked.issue=true","startTime":223.7999999821186,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":223.7999999821186,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":654.4000000059605,"responseStart":0,"secureConnectionStart":0},{"duration":454.19999998807907,"initiatorType":"script","name":"https://jira.mariadb.org/s/5d5e8fe91fbc506585e83ea3b62ccc4b-CDN/lu2cib/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/js/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.js?jira.create.linked.issue=true&locale=en","startTime":224,"connectEnd":224,"connectStart":224,"domainLookupEnd":224,"domainLookupStart":224,"fetchStart":224,"redirectEnd":0,"redirectStart":0,"requestStart":664,"responseEnd":678.1999999880791,"responseStart":677.1999999880791,"secureConnectionStart":224},{"duration":644.2999999821186,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":229.40000000596046,"connectEnd":229.40000000596046,"connectStart":229.40000000596046,"domainLookupEnd":229.40000000596046,"domainLookupStart":229.40000000596046,"fetchStart":229.40000000596046,"redirectEnd":0,"redirectStart":0,"requestStart":861.7999999821186,"responseEnd":873.6999999880791,"responseStart":873,"secureConnectionStart":229.40000000596046},{"duration":800.8000000119209,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":229.69999998807907,"connectEnd":229.69999998807907,"connectStart":229.69999998807907,"domainLookupEnd":229.69999998807907,"domainLookupStart":229.69999998807907,"fetchStart":229.69999998807907,"redirectEnd":0,"redirectStart":0,"requestStart":229.69999998807907,"responseEnd":1030.5,"responseStart":1030.5,"secureConnectionStart":229.69999998807907},{"duration":340.5,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":541.1999999880791,"connectEnd":541.1999999880791,"connectStart":541.1999999880791,"domainLookupEnd":541.1999999880791,"domainLookupStart":541.1999999880791,"fetchStart":541.1999999880791,"redirectEnd":0,"redirectStart":0,"requestStart":845.6999999880791,"responseEnd":881.6999999880791,"responseStart":881.0999999940395,"secureConnectionStart":541.1999999880791},{"duration":146.69999998807907,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":921.0999999940395,"connectEnd":921.0999999940395,"connectStart":921.0999999940395,"domainLookupEnd":921.0999999940395,"domainLookupStart":921.0999999940395,"fetchStart":921.0999999940395,"redirectEnd":0,"redirectStart":0,"requestStart":1031.2999999821186,"responseEnd":1067.7999999821186,"responseStart":1067.2999999821186,"secureConnectionStart":921.0999999940395}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":34,"responseStart":215,"responseEnd":230,"domLoading":218,"domInteractive":1165,"domContentLoadedEventStart":1165,"domContentLoadedEventEnd":1214,"domComplete":1605,"loadEventStart":1605,"loadEventEnd":1605,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1132.7999999821186},{"name":"bigPipe.sidebar-id.end","time":1133.7999999821186},{"name":"bigPipe.activity-panel-pipe-id.start","time":1134.7999999821186},{"name":"bigPipe.activity-panel-pipe-id.end","time":1139.0999999940395},{"name":"activityTabFullyLoaded","time":1238.699999988079}],"measures":[],"correlationId":"a90b31e34378d4","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":117,"dbReadsTimeInMs":11,"dbConnsTimeInMs":19,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
The warnings are issued by GCC when building with -Og (optimize while trying to keep the executable debugger-friendly).