Type:
Bug
Priority:
Major
Resolution:
Fixed
Affects Version/s:
10.4(EOL) , 10.5 , 10.6 , 10.11 , 11.0(EOL) , 11.1(EOL) , 11.2(EOL) , 11.3(EOL) , 11.4 , 11.5(EOL)
I found UBSAN bugs with a long query which, when simplified, lead to many different UBSAN stacks. In reverse order from short to long query (using UniqeID's to keep this report to a reasonable length):
SELECT TRUNCATE (EXP(-1.e-2),-1.e+30);
Leads to:
UBSAN|negation of -X cannot be represented in type 'long long int'; cast to an unsigned type to negate this value to itself|sql/item_func.cc|my_double_round|Item_func_round::real_op|Item_func_hybrid_field_type::val_real_from_real_op|Type_handler_real_result::Item_func_hybrid_field_type_val_real
UBSAN|negation of -X cannot be represented in type 'long long int'; cast to an unsigned type to negate this value to itself|sql/item_func.cc|my_double_round|Type_handler::Item_send_double|Protocol::send_result_set_row|select_send::send_data
SELECT ( TRUNCATE (EXP(-1.e-2),-1.e+30) % RADIANS(-1));
Leads to (opt/dbg):
UBSAN|negation of -X cannot be represented in type 'long long int'; cast to an unsigned type to negate this value to itself|sql/item_func.cc|my_double_round|Item_func_mod::real_op|Type_handler::Item_send_double|Protocol::send_result_set_row
UBSAN|negation of -X cannot be represented in type 'long long int'; cast to an unsigned type to negate this value to itself|sql/item_func.cc|my_double_round|Item_func_round::real_op|Item_func_hybrid_field_type::val_real_from_real_op|Type_handler_real_result::Item_func_hybrid_field_type_val_real
SELECT ( TRUNCATE (EXP(-1.e-2),-1.e+30) % RADIANS(-1)) * (LAST_DAY( '1-03-30 1:29:12' ) MOD 1 + COS(-1));
Leads to (opt/dbg):
UBSAN|negation of -X cannot be represented in type 'long long int'; cast to an unsigned type to negate this value to itself|sql/item_func.cc|my_double_round|Item_func_mod::real_op|Item_func_mul::real_op|Type_handler::Item_send_double
UBSAN|negation of -X cannot be represented in type 'long long int'; cast to an unsigned type to negate this value to itself|sql/item_func.cc|my_double_round|Item_func_round::real_op|Item_func_hybrid_field_type::val_real_from_real_op|Type_handler_real_result::Item_func_hybrid_field_type_val_real
SELECT (ASIN(-1)+ LN(-1)) % (ATAN(-1) MOD FLOOR(1)) * ( TRUNCATE (EXP(-1.e-2),-1.e+30) % RADIANS(-1)) * (LAST_DAY( '1-03-30 1:29:12' ) MOD 1 + COS(-1));
Leads to (opt/dbg):
UBSAN|negation of -X cannot be represented in type 'long long int'; cast to an unsigned type to negate this value to itself|sql/item_func.cc|my_double_round|Item_func_mod::real_op|Item_func_mul::real_op|Item_func_mul::real_op
UBSAN|negation of -X cannot be represented in type 'long long int'; cast to an unsigned type to negate this value to itself|sql/item_func.cc|my_double_round|Item_func_round::real_op|Item_func_hybrid_field_type::val_real_from_real_op|Type_handler_real_result::Item_func_hybrid_field_type_val_real
The optimized outcomes are different for each testcase. The debug build outcomes are the same for the last three only, but different from the first testcase. However, for the first testcase the optimized build outcome is the same outcome as the three last testcases debug build outcomes.
All versions and build types affected.
Setup:
Compiled with GCC >=7.5.0 (I use GCC 11.4.0) and:
-DWITH_ASAN=ON -DWITH_ASAN_SCOPE=ON -DWITH_UBSAN=ON -DWITH_RAPID=OFF -DWSREP_LIB_WITH_ASAN=ON
Set before execution:
export UBSAN_OPTIONS=print_stacktrace=1
{"report":{"fcp":3195.5,"ttfb":195.30000019073486,"pageVisibility":"visible","entityId":128063,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"a7f1ab83-4a11-4f52-a32c-56b13957814e","navigationType":0,"readyForUser":3274.1000003814697,"redirectCount":0,"resourceLoadedEnd":3608.699999809265,"resourceLoadedStart":203.30000019073486,"resourceTiming":[{"duration":2385.800000190735,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bv2/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":203.30000019073486,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":203.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":2589.1000003814697,"responseStart":0,"secureConnectionStart":0},{"duration":2532.8999996185303,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2bv2/820016/12ta74/2380add21a9a1006587582385952de73/_/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":203.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":203.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":2736.3999996185303,"responseStart":0,"secureConnectionStart":0},{"duration":2541.9000005722046,"initiatorType":"script","name":"https://jira.mariadb.org/s/e9b27a47da5fb0f74a35acd57e9847fb-CDN/lu2bv2/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":203.69999980926514,"connectEnd":203.69999980926514,"connectStart":203.69999980926514,"domainLookupEnd":203.69999980926514,"domainLookupStart":203.69999980926514,"fetchStart":203.69999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":203.69999980926514,"responseEnd":2745.6000003814697,"responseStart":2745.6000003814697,"secureConnectionStart":203.69999980926514},{"duration":2591,"initiatorType":"script","name":"https://jira.mariadb.org/s/c32eb0da7ad9831253f8397e6cc26afd-CDN/lu2bv2/820016/12ta74/2380add21a9a1006587582385952de73/_/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":203.80000019073486,"connectEnd":203.80000019073486,"connectStart":203.80000019073486,"domainLookupEnd":203.80000019073486,"domainLookupStart":203.80000019073486,"fetchStart":203.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":203.80000019073486,"responseEnd":2794.800000190735,"responseStart":2794.800000190735,"secureConnectionStart":203.80000019073486},{"duration":2594.5,"initiatorType":"script","name":"https://jira.mariadb.org/s/bc0bcb146314416123c992714ee00ff7-CDN/lu2bv2/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":204.10000038146973,"connectEnd":204.10000038146973,"connectStart":204.10000038146973,"domainLookupEnd":204.10000038146973,"domainLookupStart":204.10000038146973,"fetchStart":204.10000038146973,"redirectEnd":0,"redirectStart":0,"requestStart":204.10000038146973,"responseEnd":2798.6000003814697,"responseStart":2798.6000003814697,"secureConnectionStart":204.10000038146973},{"duration":2595.6000003814697,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":204.19999980926514,"connectEnd":204.19999980926514,"connectStart":204.19999980926514,"domainLookupEnd":204.19999980926514,"domainLookupStart":204.19999980926514,"fetchStart":204.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":204.19999980926514,"responseEnd":2799.800000190735,"responseStart":2799.800000190735,"secureConnectionStart":204.19999980926514},{"duration":2596.199999809265,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","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":2800.699999809265,"responseStart":2800.699999809265,"secureConnectionStart":204.5},{"duration":2682.5,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2bv2/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":204.60000038146973,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":204.60000038146973,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":2887.1000003814697,"responseStart":0,"secureConnectionStart":0},{"duration":2596.8999996185303,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":204.80000019073486,"connectEnd":204.80000019073486,"connectStart":204.80000019073486,"domainLookupEnd":204.80000019073486,"domainLookupStart":204.80000019073486,"fetchStart":204.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":204.80000019073486,"responseEnd":2801.699999809265,"responseStart":2801.699999809265,"secureConnectionStart":204.80000019073486},{"duration":2682.300000190735,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2bv2/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":204.89999961853027,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":204.89999961853027,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":2887.199999809265,"responseStart":0,"secureConnectionStart":0},{"duration":2597.699999809265,"initiatorType":"script","name":"https://jira.mariadb.org/s/719848dd97ebe0663199f49a3936487a-CDN/lu2bv2/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.10000038146973,"connectEnd":205.10000038146973,"connectStart":205.10000038146973,"domainLookupEnd":205.10000038146973,"domainLookupStart":205.10000038146973,"fetchStart":205.10000038146973,"redirectEnd":0,"redirectStart":0,"requestStart":205.10000038146973,"responseEnd":2802.800000190735,"responseStart":2802.800000190735,"secureConnectionStart":205.10000038146973},{"duration":3017.8999996185303,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":210,"connectEnd":210,"connectStart":210,"domainLookupEnd":210,"domainLookupStart":210,"fetchStart":210,"redirectEnd":0,"redirectStart":0,"requestStart":210,"responseEnd":3227.8999996185303,"responseStart":3227.8999996185303,"secureConnectionStart":210},{"duration":3398.300000190735,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":210.39999961853027,"connectEnd":210.39999961853027,"connectStart":210.39999961853027,"domainLookupEnd":210.39999961853027,"domainLookupStart":210.39999961853027,"fetchStart":210.39999961853027,"redirectEnd":0,"redirectStart":0,"requestStart":210.39999961853027,"responseEnd":3608.699999809265,"responseStart":3608.6000003814697,"secureConnectionStart":210.39999961853027},{"duration":333.80000019073486,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":2898.300000190735,"connectEnd":2898.300000190735,"connectStart":2898.300000190735,"domainLookupEnd":2898.300000190735,"domainLookupStart":2898.300000190735,"fetchStart":2898.300000190735,"redirectEnd":0,"redirectStart":0,"requestStart":2898.300000190735,"responseEnd":3232.1000003814697,"responseStart":3232.1000003814697,"secureConnectionStart":2898.300000190735},{"duration":437.19999980926514,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":3188.800000190735,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":3188.800000190735,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":3626,"responseStart":0,"secureConnectionStart":0}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":31,"responseStart":195,"responseEnd":210,"domLoading":201,"domInteractive":3679,"domContentLoadedEventStart":3679,"domContentLoadedEventEnd":3718,"domComplete":4952,"loadEventStart":4952,"loadEventEnd":4953,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":3610.699999809265},{"name":"bigPipe.sidebar-id.end","time":3611.6000003814697},{"name":"bigPipe.activity-panel-pipe-id.start","time":3611.699999809265},{"name":"bigPipe.activity-panel-pipe-id.end","time":3614.1000003814697},{"name":"activityTabFullyLoaded","time":3724.1000003814697}],"measures":[],"correlationId":"577562fbf14d4","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":97,"dbReadsTimeInMs":10,"dbConnsTimeInMs":18,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}