Type:
Bug
Priority:
Critical
Resolution:
Fixed
Affects Version/s:
10.4(EOL) , 10.5 , 10.6 , 10.11 , 11.1(EOL)
The following test case from opt_tvc.test fails if the server is built with-DWITH_PROTECT_STATEMENT_MEMROOT:BOOL=ON
create table t1 (a int , b int );
insert into t1
values (1,2), (4,6), (9,7), (1,1), (2,5), (7,8);
set @@in_predicate_conversion_threshold= 2;
prepare stmt from "select * from t1 where a in (1,2)" ;
execute stmt;
execute stmt;
The test case fails with the assertion abort that points to statement memory allocation at the second execution in this code of table_value_constr::prepare()
Type_holder *holders;
...
if (!(holders= new (thd->stmt_arena->mem_root) Type_holder[cnt]) ||
join_type_handlers_for_tvc(thd, li, holders, cnt) ||
get_type_attributes_for_tvc(thd, li, holders,
lists_of_values.elements, cnt))
Igor Babaev (Inactive)
made changes -
2023-09-22 03:46
Field
Original Value
New Value
Priority
Major
[ 3
]
Critical
[ 2
]
Igor Babaev (Inactive)
made changes -
2023-09-22 05:11
Assignee
Igor Babaev
[ igor
]
Oleksandr Byelkin
[ sanja
]
Status
In Progress
[ 3
]
In Review
[ 10002
]
Oleksandr Byelkin
made changes -
2023-09-22 06:48
Assignee
Oleksandr Byelkin
[ sanja
]
Igor Babaev
[ igor
]
Status
In Review
[ 10002
]
Stalled
[ 10000
]
Igor Babaev (Inactive)
made changes -
2023-09-26 05:12
Fix Version/s
10.4.32
[ 29300
]
Fix Version/s
10.5.23
[ 29012
]
Fix Version/s
10.6.16
[ 29014
]
Fix Version/s
10.10.7
[ 29018
]
Fix Version/s
10.11.6
[ 29020
]
Fix Version/s
11.0.4
[ 29021
]
Fix Version/s
11.1.3
[ 29023
]
Fix Version/s
11.2.2
[ 29035
]
Fix Version/s
10.4
[ 22408
]
Resolution
Fixed
[ 1
]
Status
Stalled
[ 10000
]
Closed
[ 6
]
Julien Fritsch
made changes -
2023-09-26 05:12
Fix Version/s
11.2.2
[ 29035
]
{"report":{"fcp":1249.7999999523163,"ttfb":347.09999990463257,"pageVisibility":"visible","entityId":125189,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"863ee35b-b21c-483b-b52f-ac9ca98204e3","navigationType":0,"readyForUser":1352.7999999523163,"redirectCount":0,"resourceLoadedEnd":1436.5999999046326,"resourceLoadedStart":365.5,"resourceTiming":[{"duration":170,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":365.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":365.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":535.5,"responseStart":0,"secureConnectionStart":0},{"duration":170,"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":365.7999999523163,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":365.7999999523163,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":535.7999999523163,"responseStart":0,"secureConnectionStart":0},{"duration":188.29999995231628,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":366,"connectEnd":366,"connectStart":366,"domainLookupEnd":366,"domainLookupStart":366,"fetchStart":366,"redirectEnd":0,"redirectStart":0,"requestStart":366,"responseEnd":554.2999999523163,"responseStart":554.2999999523163,"secureConnectionStart":366},{"duration":462.2000000476837,"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":366.2999999523163,"connectEnd":366.2999999523163,"connectStart":366.2999999523163,"domainLookupEnd":366.2999999523163,"domainLookupStart":366.2999999523163,"fetchStart":366.2999999523163,"redirectEnd":0,"redirectStart":0,"requestStart":366.2999999523163,"responseEnd":828.5,"responseStart":828.5,"secureConnectionStart":366.2999999523163},{"duration":466.19999980926514,"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":366.5,"connectEnd":366.5,"connectStart":366.5,"domainLookupEnd":366.5,"domainLookupStart":366.5,"fetchStart":366.5,"redirectEnd":0,"redirectStart":0,"requestStart":366.5,"responseEnd":832.6999998092651,"responseStart":832.6999998092651,"secureConnectionStart":366.5},{"duration":466.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":366.69999980926514,"connectEnd":366.69999980926514,"connectStart":366.69999980926514,"domainLookupEnd":366.69999980926514,"domainLookupStart":366.69999980926514,"fetchStart":366.69999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":366.69999980926514,"responseEnd":833.1999998092651,"responseStart":833.1999998092651,"secureConnectionStart":366.69999980926514},{"duration":466.7000000476837,"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":366.89999985694885,"connectEnd":366.89999985694885,"connectStart":366.89999985694885,"domainLookupEnd":366.89999985694885,"domainLookupStart":366.89999985694885,"fetchStart":366.89999985694885,"redirectEnd":0,"redirectStart":0,"requestStart":366.89999985694885,"responseEnd":833.5999999046326,"responseStart":833.5999999046326,"secureConnectionStart":366.89999985694885},{"duration":467.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":367,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":367,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":834.8999998569489,"responseStart":0,"secureConnectionStart":0},{"duration":467,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":367.19999980926514,"connectEnd":367.19999980926514,"connectStart":367.19999980926514,"domainLookupEnd":367.19999980926514,"domainLookupStart":367.19999980926514,"fetchStart":367.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":367.19999980926514,"responseEnd":834.1999998092651,"responseStart":834.1999998092651,"secureConnectionStart":367.19999980926514},{"duration":467.60000014305115,"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":367.39999985694885,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":367.39999985694885,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":835,"responseStart":0,"secureConnectionStart":0},{"duration":467.09999990463257,"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":367.59999990463257,"connectEnd":367.59999990463257,"connectStart":367.59999990463257,"domainLookupEnd":367.59999990463257,"domainLookupStart":367.59999990463257,"fetchStart":367.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":367.59999990463257,"responseEnd":834.6999998092651,"responseStart":834.6999998092651,"secureConnectionStart":367.59999990463257},{"duration":643.5999999046326,"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":368.59999990463257,"connectEnd":368.59999990463257,"connectStart":368.59999990463257,"domainLookupEnd":368.59999990463257,"domainLookupStart":368.59999990463257,"fetchStart":368.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":368.59999990463257,"responseEnd":1012.1999998092651,"responseStart":1012.1999998092651,"secureConnectionStart":368.59999990463257},{"duration":1061.6999998092651,"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":373.5,"connectEnd":373.5,"connectStart":373.5,"domainLookupEnd":373.5,"domainLookupStart":373.5,"fetchStart":373.5,"redirectEnd":0,"redirectStart":0,"requestStart":373.5,"responseEnd":1435.1999998092651,"responseStart":1435.1999998092651,"secureConnectionStart":373.5},{"duration":224.20000004768372,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":737.3999998569489,"connectEnd":737.3999998569489,"connectStart":737.3999998569489,"domainLookupEnd":737.3999998569489,"domainLookupStart":737.3999998569489,"fetchStart":737.3999998569489,"redirectEnd":0,"redirectStart":0,"requestStart":737.3999998569489,"responseEnd":961.5999999046326,"responseStart":961.5999999046326,"secureConnectionStart":737.3999998569489},{"duration":307.90000009536743,"initiatorType":"link","name":"https://jira.mariadb.org/s/d5715adaadd168a9002b108b2b039b50-CDN/lu2cib/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&whisper-enabled=true","startTime":1128.6999998092651,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1128.6999998092651,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1436.5999999046326,"responseStart":0,"secureConnectionStart":0},{"duration":372.30000019073486,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/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&whisper-enabled=true","startTime":1129.6999998092651,"connectEnd":1129.6999998092651,"connectStart":1129.6999998092651,"domainLookupEnd":1129.6999998092651,"domainLookupStart":1129.6999998092651,"fetchStart":1129.6999998092651,"redirectEnd":0,"redirectStart":0,"requestStart":1129.6999998092651,"responseEnd":1502,"responseStart":1502,"secureConnectionStart":1129.6999998092651},{"duration":396.7000000476837,"initiatorType":"script","name":"https://jira.mariadb.org/s/097ae97cb8fbec7d6ea4bbb1f26955b9-CDN/lu2cib/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&whisper-enabled=true","startTime":1130.0999999046326,"connectEnd":1130.0999999046326,"connectStart":1130.0999999046326,"domainLookupEnd":1130.0999999046326,"domainLookupStart":1130.0999999046326,"fetchStart":1130.0999999046326,"redirectEnd":0,"redirectStart":0,"requestStart":1130.0999999046326,"responseEnd":1526.7999999523163,"responseStart":1526.7999999523163,"secureConnectionStart":1130.0999999046326}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":150,"responseStart":347,"responseEnd":363,"domLoading":352,"domInteractive":1495,"domContentLoadedEventStart":1495,"domContentLoadedEventEnd":1564,"domComplete":1930,"loadEventStart":1931,"loadEventEnd":1931,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1439.2999999523163},{"name":"bigPipe.sidebar-id.end","time":1440.1999998092651},{"name":"bigPipe.activity-panel-pipe-id.start","time":1440.3999998569489},{"name":"bigPipe.activity-panel-pipe-id.end","time":1447},{"name":"activityTabFullyLoaded","time":1589.0999999046326}],"measures":[],"correlationId":"ae6bd13059a49","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":134,"dbReadsTimeInMs":20,"dbConnsTimeInMs":30,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
The following patch fixes this problem:
diff --git a/libmariadb b/libmariadb
--- a/libmariadb
+++ b/libmariadb
@@ -1 +1 @@
-Subproject commit 3393fe35d378744e12636766931cf5109cc6c2e5
+Subproject commit 3393fe35d378744e12636766931cf5109cc6c2e5-dirty
diff --git a/sql/sql_tvc.cc b/sql/sql_tvc.cc
index 71377d3..13dfde6 100644
--- a/sql/sql_tvc.cc
+++ b/sql/sql_tvc.cc
@@ -227,7 +227,7 @@ bool table_value_constr::prepare(THD *thd, SELECT_LEX *sl,
List_item *first_elem= li++;
uint cnt= first_elem->elements;
- Type_holder *holders;
+ Type_holder *holders= type_holders;
if (cnt == 0)
{
@@ -238,32 +238,35 @@ bool table_value_constr::prepare(THD *thd, SELECT_LEX *sl,
if (fix_fields_for_tvc(thd, li))
DBUG_RETURN(true);
- if (!(holders= new (thd->stmt_arena->mem_root) Type_holder[cnt]) ||
- join_type_handlers_for_tvc(thd, li, holders, cnt) ||
- get_type_attributes_for_tvc(thd, li, holders,
- lists_of_values.elements, cnt))
- DBUG_RETURN(true);
-
- List_iterator_fast<Item> it(*first_elem);
- Item *item;
- Query_arena *arena, backup;
- arena=thd->activate_stmt_arena_if_needed(&backup);
-
- sl->item_list.empty();
- for (uint pos= 0; (item= it++); pos++)
+ if (!holders)
{
- /* Error's in 'new' will be detected after loop */
- Item_type_holder *new_holder= new (thd->mem_root)
- Item_type_holder(thd, item, holders[pos].type_handler(),
- &holders[pos]/*Type_all_attributes*/,
- holders[pos].get_maybe_null());
- sl->item_list.push_back(new_holder);
- }
- if (arena)
- thd->restore_active_arena(arena, &backup);
-
- if (unlikely(thd->is_fatal_error))
- DBUG_RETURN(true); // out of memory
+ holders= type_holders= new (thd->stmt_arena->mem_root) Type_holder[cnt];
+ if (!holders ||
+ join_type_handlers_for_tvc(thd, li, holders, cnt) ||
+ get_type_attributes_for_tvc(thd, li, holders,
+ lists_of_values.elements, cnt))
+ DBUG_RETURN(true);
+ List_iterator_fast<Item> it(*first_elem);
+ Item *item;
+ Query_arena *arena, backup;
+ arena=thd->activate_stmt_arena_if_needed(&backup);
+
+ sl->item_list.empty();
+ for (uint pos= 0; (item= it++); pos++)
+ {
+ /* Error's in 'new' will be detected after loop */
+ Item_type_holder *new_holder= new (thd->mem_root)
+ Item_type_holder(thd, item, holders[pos].type_handler(),
+ &holders[pos]/*Type_all_attributes*/,
+ holders[pos].get_maybe_null());
+ sl->item_list.push_back(new_holder);
+ }
+ if (arena)
+ thd->restore_active_arena(arena, &backup);
+
+ if (unlikely(thd->is_fatal_error))
+ DBUG_RETURN(true); // out of memory
}
- if (arena)
- thd->restore_active_arena(arena, &backup);
-
- if (unlikely(thd->is_fatal_error))
- DBUG_RETURN(true); // out of memory
result= tmp_result;
diff --git a/sql/sql_tvc.h b/sql/sql_tvc.h
index 594a77a..cdd5f52 100644
--- a/sql/sql_tvc.h
+++ b/sql/sql_tvc.h
@@ -24,6 +24,7 @@ class Explain_query;
class Item_func_in;
class st_select_lex_unit;
typedef class st_select_lex SELECT_LEX;
+class Type_holder;
/**
@class table_value_constr
@@ -38,6 +39,7 @@ class table_value_constr : public Sql_alloc
List<List_item> lists_of_values;
select_result *result;
SELECT_LEX *select_lex;
+ Type_holder *type_holders;
enum { QEP_NOT_PRESENT_YET, QEP_AVAILABLE} have_query_plan;
@@ -46,7 +48,7 @@ class table_value_constr : public Sql_alloc
table_value_constr(List<List_item> tvc_values, SELECT_LEX *sl,
ulonglong select_options_arg) :
- lists_of_values(tvc_values), result(0), select_lex(sl),
+ lists_of_values(tvc_values), result(0), select_lex(sl), type_holders(0),
have_query_plan(QEP_NOT_PRESENT_YET), explain(0),
select_options(select_options_arg)
{ };