[MDEV-11566] Server crashes in get_store_key / create_ref_for_key / get_best_combination Created: 2016-12-14 Updated: 2023-06-08 Resolved: 2023-06-08 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Optimizer, Storage Engine - InnoDB |
| Affects Version/s: | 5.5, 10.0, 10.1, 10.2 |
| Fix Version/s: | N/A |
| Type: | Bug | Priority: | Major |
| Reporter: | Elena Stepanova | Assignee: | Igor Babaev |
| Resolution: | Won't Fix | Votes: | 1 |
| Labels: | None | ||
| Attachments: |
|
||||||||||||
| Issue Links: |
|
||||||||||||
| Sprint: | 10.2.6-3, 5.5.58 | ||||||||||||
| Description |
|
Initially reported on #maria IRC channel.
Does not crash with MyISAM.
|
| Comments |
| Comment by Sergei Petrunia [ 2017-02-17 ] | ||||||||||||||||||||||||||||||||
|
Varun, please investigate. | ||||||||||||||||||||||||||||||||
| Comment by Varun Gupta (Inactive) [ 2017-03-13 ] | ||||||||||||||||||||||||||||||||
|
shows segfault for this
so clearly we can see that Item_ref::ref is not pointing to a valid memory address | ||||||||||||||||||||||||||||||||
| Comment by Varun Gupta (Inactive) [ 2017-03-15 ] | ||||||||||||||||||||||||||||||||
|
So now we start to find where Item_ref->ref is initialised In function Item_field::fix_outer_field
The value returned from the function resolve_ref_in_select_and_group is
| ||||||||||||||||||||||||||||||||
| Comment by Varun Gupta (Inactive) [ 2017-03-20 ] | ||||||||||||||||||||||||||||||||
|
In function find_field_in_tables, we find the reference for orig_instances_id
Next we find try find the outer reference for orig.instances_id in the outer select and group by clause Inside the function resolve_ref_in_select_and_group, we first find the ref in
This all looks to work correctly. Now back to function Item_field:: fix_outer_field
| ||||||||||||||||||||||||||||||||
| Comment by Varun Gupta (Inactive) [ 2017-03-21 ] | ||||||||||||||||||||||||||||||||
|
One strange thing I found is
the type is FIELD_ITEM which is correct, so we should only compute
if the type of the object is REF_ITEM | ||||||||||||||||||||||||||||||||
| Comment by Varun Gupta (Inactive) [ 2017-03-23 ] | ||||||||||||||||||||||||||||||||
|
| ||||||||||||||||||||||||||||||||
| Comment by Varun Gupta (Inactive) [ 2017-03-23 ] | ||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2017-06-29 ] | ||||||||||||||||||||||||||||||||
|
Looking at the code before the patch...
Debugging the bug's example:
so the computation arrives to the line marked with
Item_outer_ref points to an Item_field.
That is, ref is casted to Item_ref*, while it points to an Item_field object. | ||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2017-06-29 ] | ||||||||||||||||||||||||||||||||
|
Looking at varun's patch. It still casts keyuse->val->ref to point to an Item_ref:
while the object located at that address is an Item_field. | ||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2017-06-29 ] | ||||||||||||||||||||||||||||||||
|
Also checked with sanja : it is normal to have Item_outer_ref(Item_field(...)). | ||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2017-06-29 ] | ||||||||||||||||||||||||||||||||
|
varun, please fix the patch to not do invalid typecast. | ||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2017-07-04 ] | ||||||||||||||||||||||||||||||||
|
As far as I understand, we can use store_key_field (a direct field-to-field copier) for items in this form:
where X is an Item_field object. A counter-example: we cannot use store_key_field for Item_ref(Item_field(X)). This is because Item_ref converts val_int() (and similar) calls to val_result() (and similar) calls. So we would need to use Item_field->result_item there (which we do not do ATM). | ||||||||||||||||||||||||||||||||
| Comment by Varun Gupta (Inactive) [ 2019-01-17 ] | ||||||||||||||||||||||||||||||||
|
Patch | ||||||||||||||||||||||||||||||||
| Comment by Alice Sherepa [ 2021-11-02 ] | ||||||||||||||||||||||||||||||||
|
not reproducible on the current 10.2 d0b611a76d91a5b6dbbc8 | ||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2023-06-08 ] | ||||||||||||||||||||||||||||||||
|
10.1 and even 10.2 are long EOL, and it's not reproducible on higher versions. |