After update to latest GCC 10, I see the aforementioned test failing. I use -flto that enables cross module inlining and I investigated that stack overflow detection does not work in `check_stack_overrun` function in sql_parse.cc. It's very likely caused by optimized out the allocation of buf argument of the function, which is a stack variable in a caller frame.
I'm suggesting the following patch:
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index a8e66d2a..9cbf23d7 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -7229,10 +7229,14 @@ long max_stack_used;
corresponding exec. (Thus we only have to check in fix_fields.)
- Passing to check_stack_overrun() prevents the compiler from removing it.
*/
-bool check_stack_overrun(THD *thd, long margin,
- uchar *buf __attribute__((unused)))
+bool check_stack_overrun(THD *thd, long margin, uchar *buf)
{
long stack_used;
+ /*
+ Take address of the buf argument in order to prevent
+ the stack allocation made this function caller.
+ */
+ staticvolatile uchar *buf_ptr = buf;
DBUG_ASSERT(thd == current_thd);
if ((stack_used= available_stack_size(thd->thread_stack, &stack_used)) >=
Yes, I think both attributes and pragma could be accepted as a solution. Both are a way to tell the compiler what it should not optimize, both aren't portable, but it's ok, as the optimization issue is compiler specific anyway, so a compiler specific fix is fine here.
Sergei Golubchik
added a comment - Yes, I think both attributes and pragma could be accepted as a solution. Both are a way to tell the compiler what it should not optimize, both aren't portable, but it's ok, as the optimization issue is compiler specific anyway, so a compiler specific fix is fine here.
Sergei Golubchik
added a comment - - edited the last ( https://github.com/MariaDB/server/pull/1424/commits/c1584b72097c385d2cb59d4e27c958168f78e0e6 ) commit looks ok, could you, please, push it?
People
Anel Husakovic
Martin Liška
Votes:
0Vote for this issue
Watchers:
4Start 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":1088.1000001430511,"ttfb":383,"pageVisibility":"visible","entityId":81008,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"cc0ca504-def5-4a77-aaea-316f3003ee00","navigationType":0,"readyForUser":1181.7000000476837,"redirectCount":0,"resourceLoadedEnd":954.3000001907349,"resourceLoadedStart":390.30000019073486,"resourceTiming":[{"duration":170.89999985694885,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":390.30000019073486,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":390.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":561.2000000476837,"responseStart":0,"secureConnectionStart":0},{"duration":171.29999995231628,"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":390.60000014305115,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":390.60000014305115,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":561.9000000953674,"responseStart":0,"secureConnectionStart":0},{"duration":210.40000009536743,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":390.90000009536743,"connectEnd":390.90000009536743,"connectStart":390.90000009536743,"domainLookupEnd":390.90000009536743,"domainLookupStart":390.90000009536743,"fetchStart":390.90000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":564.4000000953674,"responseEnd":601.3000001907349,"responseStart":577.3000001907349,"secureConnectionStart":390.90000009536743},{"duration":219.70000004768372,"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":391,"connectEnd":391,"connectStart":391,"domainLookupEnd":391,"domainLookupStart":391,"fetchStart":391,"redirectEnd":0,"redirectStart":0,"requestStart":565.3000001907349,"responseEnd":610.7000000476837,"responseStart":579.4000000953674,"secureConnectionStart":391},{"duration":197.10000014305115,"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":391.2000000476837,"connectEnd":391.2000000476837,"connectStart":391.2000000476837,"domainLookupEnd":391.2000000476837,"domainLookupStart":391.2000000476837,"fetchStart":391.2000000476837,"redirectEnd":0,"redirectStart":0,"requestStart":566.7000000476837,"responseEnd":588.3000001907349,"responseStart":587.3000001907349,"secureConnectionStart":391.2000000476837},{"duration":195.70000004768372,"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":391.40000009536743,"connectEnd":391.40000009536743,"connectStart":391.40000009536743,"domainLookupEnd":391.40000009536743,"domainLookupStart":391.40000009536743,"fetchStart":391.40000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":567.5,"responseEnd":587.1000001430511,"responseStart":586.5,"secureConnectionStart":391.40000009536743},{"duration":200.70000004768372,"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":391.5,"connectEnd":391.5,"connectStart":391.5,"domainLookupEnd":391.5,"domainLookupStart":391.5,"fetchStart":391.5,"redirectEnd":0,"redirectStart":0,"requestStart":570.3000001907349,"responseEnd":592.2000000476837,"responseStart":591.6000001430511,"secureConnectionStart":391.5},{"duration":176.89999985694885,"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":391.60000014305115,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":391.60000014305115,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":568.5,"responseStart":0,"secureConnectionStart":0},{"duration":203.19999980926514,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":391.80000019073486,"connectEnd":391.80000019073486,"connectStart":391.80000019073486,"domainLookupEnd":391.80000019073486,"domainLookupStart":391.80000019073486,"fetchStart":391.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":572,"responseEnd":595,"responseStart":594.4000000953674,"secureConnectionStart":391.80000019073486},{"duration":178.5,"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":391.90000009536743,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":391.90000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":570.4000000953674,"responseStart":0,"secureConnectionStart":0},{"duration":202.20000004768372,"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":392.10000014305115,"connectEnd":392.10000014305115,"connectStart":392.10000014305115,"domainLookupEnd":392.10000014305115,"domainLookupStart":392.10000014305115,"fetchStart":392.10000014305115,"redirectEnd":0,"redirectStart":0,"requestStart":572.8000001907349,"responseEnd":594.3000001907349,"responseStart":593.7000000476837,"secureConnectionStart":392.10000014305115},{"duration":552.6000001430511,"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":400.5,"connectEnd":400.5,"connectStart":400.5,"domainLookupEnd":400.5,"domainLookupStart":400.5,"fetchStart":400.5,"redirectEnd":0,"redirectStart":0,"requestStart":811.9000000953674,"responseEnd":953.1000001430511,"responseStart":950,"secureConnectionStart":400.5},{"duration":551.6000001430511,"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":402.7000000476837,"connectEnd":402.7000000476837,"connectStart":402.7000000476837,"domainLookupEnd":402.7000000476837,"domainLookupStart":402.7000000476837,"fetchStart":402.7000000476837,"redirectEnd":0,"redirectStart":0,"requestStart":812.2000000476837,"responseEnd":954.3000001907349,"responseStart":950.6000001430511,"secureConnectionStart":402.7000000476837},{"duration":201.30000019073486,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":803,"connectEnd":803,"connectStart":803,"domainLookupEnd":803,"domainLookupStart":803,"fetchStart":803,"redirectEnd":0,"redirectStart":0,"requestStart":965.5,"responseEnd":1004.3000001907349,"responseStart":1003.4000000953674,"secureConnectionStart":803},{"duration":269.5,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":1068.8000001907349,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1068.8000001907349,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1338.3000001907349,"responseStart":0,"secureConnectionStart":0},{"duration":212.89999985694885,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":1087.1000001430511,"connectEnd":1087.1000001430511,"connectStart":1087.1000001430511,"domainLookupEnd":1087.1000001430511,"domainLookupStart":1087.1000001430511,"fetchStart":1087.1000001430511,"redirectEnd":0,"redirectStart":0,"requestStart":1264.4000000953674,"responseEnd":1300,"responseStart":1299.3000001907349,"secureConnectionStart":1087.1000001430511}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":223,"responseStart":383,"responseEnd":403,"domLoading":387,"domInteractive":1380,"domContentLoadedEventStart":1380,"domContentLoadedEventEnd":1420,"domComplete":2278,"loadEventStart":2278,"loadEventEnd":2278,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1302},{"name":"bigPipe.sidebar-id.end","time":1302.9000000953674},{"name":"bigPipe.activity-panel-pipe-id.start","time":1303.1000001430511},{"name":"bigPipe.activity-panel-pipe-id.end","time":1304.9000000953674},{"name":"activityTabFullyLoaded","time":1442.1000001430511}],"measures":[],"correlationId":"9eaae9885bcace","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":96,"dbReadsTimeInMs":12,"dbConnsTimeInMs":23,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
Is there a consensus that using -O0 will be accepted in a pull request?