When the code is compiled with Clang 6.0.3 and cmake -DCMAKE_BUILD_TYPE=Debug -DWITH_ASAN:BOOL=ON, 3 of these 4 tests will cause a server crash instead of reporting a stack overflow error. If -O1 is added to CMAKE_C_FLAGS and CMAKE_CXX_FLAGS, then these tests will pass:
ASAN_OPTIONS=abort_on_error=1,disable_coredump=0,detect_leaks=0 ./mtr --parallel=auto --force --retry=0 --max-test-fail=0 compat/oracle.parser compat/oracle.sp-package compat/oracle.sp-package-mysqldump compat/oracle.sp-package-security
|
10.3 71144afa966a85d08053eb616a1021fd339102d1
|
CURRENT_TEST: compat/oracle.sp-package-mysqldump
|
mysqltest: At line 42: query 'CALL p1' failed: 2013: Lost connection to MySQL server during query
|
…
|
CURRENT_TEST: compat/oracle.sp-package
|
mysqltest: At line 1470: query 'CALL pack.p1('p2 pack.p3')' failed: 2013: Lost connection to MySQL server during query
|
…
|
CURRENT_TEST: compat/oracle.parser
|
mysqltest: At line 73: query 'CALL p2('date')' failed: 1436: Thread stack overrun: 240640 bytes used of a 299008 byte stack, and 81920 bytes needed. Use 'mysqld --thread_stack=#' to specify a bigger stack
|
…
|
CURRENT_TEST: compat/oracle.sp-package-security
|
mysqltest: At line 233: query 'GRANT EXECUTE ON PACKAGE BODY db1.pkg1 TO u1@localhost' failed: 2013: Lost connection to MySQL server during query
|
{"report":{"fcp":672.6000000238419,"ttfb":197.80000007152557,"pageVisibility":"visible","entityId":68472,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":1,"journeyId":"139c36fc-ce3f-46c7-b4c0-ce20174bef41","navigationType":0,"readyForUser":744.5,"redirectCount":0,"resourceLoadedEnd":840.7000000476837,"resourceLoadedStart":203.80000007152557,"resourceTiming":[{"duration":13.100000023841858,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":203.80000007152557,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":203.80000007152557,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":216.90000009536743,"responseStart":0,"secureConnectionStart":0},{"duration":13,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2bu7/820016/12ta74/8679b4946efa1a0bb029a3a22206fb5d/_/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","startTime":204.10000002384186,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":204.10000002384186,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":217.10000002384186,"responseStart":0,"secureConnectionStart":0},{"duration":67.89999997615814,"initiatorType":"script","name":"https://jira.mariadb.org/s/fbf975c0cce4b1abf04784eeae9ba1f4-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":204.20000004768372,"connectEnd":204.20000004768372,"connectStart":204.20000004768372,"domainLookupEnd":204.20000004768372,"domainLookupStart":204.20000004768372,"fetchStart":204.20000004768372,"redirectEnd":0,"redirectStart":0,"requestStart":204.20000004768372,"responseEnd":272.10000002384186,"responseStart":272.10000002384186,"secureConnectionStart":204.20000004768372},{"duration":156.5,"initiatorType":"script","name":"https://jira.mariadb.org/s/099b33461394b8015fc36c0a4b96e19f-CDN/lu2bu7/820016/12ta74/8679b4946efa1a0bb029a3a22206fb5d/_/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","startTime":204.40000009536743,"connectEnd":204.40000009536743,"connectStart":204.40000009536743,"domainLookupEnd":204.40000009536743,"domainLookupStart":204.40000009536743,"fetchStart":204.40000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":204.40000009536743,"responseEnd":360.90000009536743,"responseStart":360.90000009536743,"secureConnectionStart":204.40000009536743},{"duration":160.80000007152557,"initiatorType":"script","name":"https://jira.mariadb.org/s/94c15bff32baef80f4096a08aceae8bc-CDN/lu2bu7/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":204.5,"connectEnd":204.5,"connectStart":204.5,"domainLookupEnd":204.5,"domainLookupStart":204.5,"fetchStart":204.5,"redirectEnd":0,"redirectStart":0,"requestStart":204.5,"responseEnd":365.3000000715256,"responseStart":365.3000000715256,"secureConnectionStart":204.5},{"duration":161.5,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":204.60000002384186,"connectEnd":204.60000002384186,"connectStart":204.60000002384186,"domainLookupEnd":204.60000002384186,"domainLookupStart":204.60000002384186,"fetchStart":204.60000002384186,"redirectEnd":0,"redirectStart":0,"requestStart":204.60000002384186,"responseEnd":366.10000002384186,"responseStart":366.10000002384186,"secureConnectionStart":204.60000002384186},{"duration":161.20000004768372,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":204.60000002384186,"connectEnd":204.60000002384186,"connectStart":204.60000002384186,"domainLookupEnd":204.60000002384186,"domainLookupStart":204.60000002384186,"fetchStart":204.60000002384186,"redirectEnd":0,"redirectStart":0,"requestStart":204.60000002384186,"responseEnd":365.8000000715256,"responseStart":365.8000000715256,"secureConnectionStart":204.60000002384186},{"duration":161.89999997615814,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2bu7/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":204.70000004768372,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":204.70000004768372,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":366.60000002384186,"responseStart":0,"secureConnectionStart":0},{"duration":161.69999992847443,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":204.80000007152557,"connectEnd":204.80000007152557,"connectStart":204.80000007152557,"domainLookupEnd":204.80000007152557,"domainLookupStart":204.80000007152557,"fetchStart":204.80000007152557,"redirectEnd":0,"redirectStart":0,"requestStart":204.80000007152557,"responseEnd":366.5,"responseStart":366.5,"secureConnectionStart":204.80000007152557},{"duration":162,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2bu7/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":205,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":205,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":367,"responseStart":0,"secureConnectionStart":0},{"duration":162,"initiatorType":"script","name":"https://jira.mariadb.org/s/3339d87fa2538a859872f2df449bf8d0-CDN/lu2bu7/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":205.10000002384186,"connectEnd":205.10000002384186,"connectStart":205.10000002384186,"domainLookupEnd":205.10000002384186,"domainLookupStart":205.10000002384186,"fetchStart":205.10000002384186,"redirectEnd":0,"redirectStart":0,"requestStart":205.10000002384186,"responseEnd":367.10000002384186,"responseStart":367.10000002384186,"secureConnectionStart":205.10000002384186},{"duration":487.5,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":205.90000009536743,"connectEnd":205.90000009536743,"connectStart":205.90000009536743,"domainLookupEnd":205.90000009536743,"domainLookupStart":205.90000009536743,"fetchStart":205.90000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":205.90000009536743,"responseEnd":693.4000000953674,"responseStart":693.4000000953674,"secureConnectionStart":205.90000009536743},{"duration":496.40000009536743,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":206,"connectEnd":206,"connectStart":206,"domainLookupEnd":206,"domainLookupStart":206,"fetchStart":206,"redirectEnd":0,"redirectStart":0,"requestStart":206,"responseEnd":702.4000000953674,"responseStart":702.4000000953674,"secureConnectionStart":206},{"duration":266.2999999523163,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":427.3000000715256,"connectEnd":427.3000000715256,"connectStart":427.3000000715256,"domainLookupEnd":427.3000000715256,"domainLookupStart":427.3000000715256,"fetchStart":427.3000000715256,"redirectEnd":0,"redirectStart":0,"requestStart":427.3000000715256,"responseEnd":693.6000000238419,"responseStart":693.6000000238419,"secureConnectionStart":427.3000000715256},{"duration":41.10000002384186,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":665.8000000715256,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":665.8000000715256,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":706.9000000953674,"responseStart":0,"secureConnectionStart":0},{"duration":59.299999952316284,"initiatorType":"link","name":"https://jira.mariadb.org/s/d5715adaadd168a9002b108b2b039b50-CDN/lu2bu7/820016/12ta74/be4b45e9cec53099498fa61c8b7acba4/_/download/contextbatch/css/jira.project.sidebar,-_super,-project.issue.navigator,-jira.general,-jira.browse.project,-jira.view.issue,-jira.global,-atl.general,-com.atlassian.jira.projects.sidebar.init/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true","startTime":780.8000000715256,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":780.8000000715256,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":840.1000000238419,"responseStart":0,"secureConnectionStart":0},{"duration":59.10000002384186,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/e65b778d185daf5aee24936755b43da6/_/download/contextbatch/js/browser-metrics-plugin.contrib,-_super,-project.issue.navigator,-jira.view.issue,-atl.general/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true","startTime":781.6000000238419,"connectEnd":781.6000000238419,"connectStart":781.6000000238419,"domainLookupEnd":781.6000000238419,"domainLookupStart":781.6000000238419,"fetchStart":781.6000000238419,"redirectEnd":0,"redirectStart":0,"requestStart":781.6000000238419,"responseEnd":840.7000000476837,"responseStart":840.7000000476837,"secureConnectionStart":781.6000000238419},{"duration":105.60000002384186,"initiatorType":"script","name":"https://jira.mariadb.org/s/f51ef5507eea4c158f257c66c93b2a3f-CDN/lu2bu7/820016/12ta74/be4b45e9cec53099498fa61c8b7acba4/_/download/contextbatch/js/jira.project.sidebar,-_super,-project.issue.navigator,-jira.general,-jira.browse.project,-jira.view.issue,-jira.global,-atl.general,-com.atlassian.jira.projects.sidebar.init/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true","startTime":782,"connectEnd":782,"connectStart":782,"domainLookupEnd":782,"domainLookupStart":782,"fetchStart":782,"redirectEnd":0,"redirectStart":0,"requestStart":782,"responseEnd":887.6000000238419,"responseStart":887.6000000238419,"secureConnectionStart":782}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":25,"responseStart":198,"responseEnd":201,"domLoading":201,"domInteractive":864,"domContentLoadedEventStart":864,"domContentLoadedEventEnd":911,"domComplete":1139,"loadEventStart":1139,"loadEventEnd":1140,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":835.1000000238419},{"name":"bigPipe.sidebar-id.end","time":835.8000000715256},{"name":"bigPipe.activity-panel-pipe-id.start","time":836},{"name":"bigPipe.activity-panel-pipe-id.end","time":838.3000000715256},{"name":"activityTabFullyLoaded","time":928.8000000715256}],"measures":[],"correlationId":"6bd57dcbe37af5","effectiveType":"4g","downlink":9.7,"rtt":0,"serverDuration":104,"dbReadsTimeInMs":12,"dbConnsTimeInMs":19,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
By design, AddressSanitizer will allocate some "sentinel" areas in stack frames so that it can better catch buffer overflows, by trapping access to memory addresses that reside between stack-allocated variables.
Apparently, something has been changed in recent compilers, and I am seeing a need for a larger thread stack size when using -DWITH_ASAN=ON with GCC 12.3.0, GCC 13.2.0, or clang 16.0.6. The minimum stack size to pass bootstrap is smaller for non-debug builds, and smaller for GCC 12 than for GCC 13. Here is an example from clang 16.0.6, CMAKE_BUILD_TYPE=RelWithDebInfo and WITH_ASAN=ON:
10.6 44b9e4169412205f2f1d013d3346420aee9d09d5
main.1st [ fail ] Found warnings/errors in server log file!
Test ended at 2023-11-17 13:53:43
line
2023-11-17 13:53:42 0 [ERROR] Could not open mysql.plugin table: "Thread stack overrun: 6566560 bytes used of a 5242880 byte stack, and 81920 bytes needed. Consider increasing the thread_stack system variable.". Some plugins may be not loaded
2023-11-17 13:53:42 0 [Warning] Can't open and lock time zone table: Thread stack overrun: 8642784 bytes used of a 5242880 byte stack, and 81920 bytes needed. Consider increasing the thread_stack system variable. trying to live without them
2023-11-17 13:53:42 0 [ERROR] Can't open the mysql.func table. Please run mysql_upgrade to create it.
I don’t think that this is a bug in our actual code or the stack overflow detection, just an issue with the build parameters. The following patch fixes this for me:
diff --git a/include/my_pthread.h b/include/my_pthread.h
index 3e68538b424..31157c9f063 100644
--- a/include/my_pthread.h
+++ b/include/my_pthread.h
@@ -667,15 +667,11 @@ extern void my_mutex_end(void);
We need to have at least 256K stack to handle calls to myisamchk_init()
with the current number of keys and key parts.
*/
-#if defined(__SANITIZE_ADDRESS__) || defined(WITH_UBSAN)
-#ifndef DBUG_OFF
-#define DEFAULT_THREAD_STACK (1024*1024L)
-#else
-#define DEFAULT_THREAD_STACK (383*1024L) /* 392192 */
-#endif
-#else
-#define DEFAULT_THREAD_STACK (292*1024L) /* 299008 */
-#endif
+# if defined(__SANITIZE_ADDRESS__) || defined(WITH_UBSAN)
+# define DEFAULT_THREAD_STACK (9L<<20)
+# else
+# define DEFAULT_THREAD_STACK (292*1024L) /* 299008 */
+# endif
#endif
I think that to be on the safe side, we’d better use 10 MiB instead of the above 9 MiB. That is what I have been using in my local builds recently.
Apparently, on our CI systems, the compilers used for ASAN builds are older, because the problem has not occurred there.