Commit f70d18d
committed
MDEV-35815: use-after-poison_in_get_hash_symbol
When a PREPARED statment is executed twice, it is crashing during the
second execution.
For the following query: -
PREPARE stmt FROM 'SELECT tbl.subject AS fld FROM v1 AS tbl
GROUP BY fld HAVING 0 AND fld != 1';
Here v1 is a view on top of a table having a single longtext column.
The column "subject" in v1 is defined as an expression using "ifnull"
function.
During the first execution:
The Item "fld" in the HAVING clause, is an Item_ref instance with name
"fld", where it has a ref to another Item_ref instance with the same name "fld"
which in turn has a reference to another Item with name "subject".
In the join prepare stage, while in the call to setup_copy_fields() from
make_aggr_tables_info(), the name field of the last Item instance
is replaced with the name in second Item_ref instance. However, after
the first execution is done, the meory for the second Item_ref is freed.
Now, during the second execution of the same statement, when trying to
access name field Item_ref instance, it was getting crashed, because,
that memory was already freed earlier.
The fix is to allocate a new memory in the stmt_arena for the second
Item_ref instance's name->str field.1 parent 21395bb commit f70d18d
3 files changed
+48
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1001 | 1001 | | |
1002 | 1002 | | |
1003 | 1003 | | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1056 | 1056 | | |
1057 | 1057 | | |
1058 | 1058 | | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28086 | 28086 | | |
28087 | 28087 | | |
28088 | 28088 | | |
| 28089 | + | |
| 28090 | + | |
| 28091 | + | |
| 28092 | + | |
| 28093 | + | |
| 28094 | + | |
| 28095 | + | |
28089 | 28096 | | |
28090 | 28097 | | |
28091 | 28098 | | |
| |||
0 commit comments