[MDEV-31113] Server crashes in store_length / Type_handler_string_result::make_sort_key with DISTINCT and group function Created: 2023-04-23 Updated: 2023-07-26 Resolved: 2023-04-28 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Optimizer |
| Affects Version/s: | 10.4, 10.5, 10.6, 10.7, 10.8, 10.9, 10.10, 10.11, 11.0 |
| Fix Version/s: | 11.1.1, 10.11.3, 11.0.2, 10.4.29, 10.5.20, 10.6.13, 10.8.8, 10.9.6, 10.10.4 |
| Type: | Bug | Priority: | Blocker |
| Reporter: | Elena Stepanova | Assignee: | Oleg Smirnov |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | regression | ||
| Description |
|
Note: The query in the test case doesn't look meaningful, but I'm not sure the problem is limited to such nonsensical queries. If the analysis shows that it indeed does, I don't object demoting it from a blocker.
The failure started happening on 10.4+ after this commit:
|
| Comments |
| Comment by Elena Stepanova [ 2023-04-24 ] | |||||||||||||
|
I suppose this failure is related to the initially reported:
| |||||||||||||
| Comment by Sergei Petrunia [ 2023-04-24 ] | |||||||||||||
|
The problem starts here:
We crash because of non-sensical value:
Which comes from
where
| |||||||||||||
| Comment by Sergei Petrunia [ 2023-04-24 ] | |||||||||||||
|
Doesn't seem to be directly related to I see a mismatch between We use collation latin1_swedish_ci. latin1_swedish_ci!= &my_charset_bin but also for ituse_strnxfrm(...)= false, so Type_handler_string_result::sortlength() function doesn't set suffix_length. But the code in Type_handler_string_result::make_sort_key() will try to read suffix_length if use_strnxfrm(cs)==false. oleg.smirnov, can you check the above reasoning. Any clue? Please ask bar if necessary. | |||||||||||||
| Comment by Oleg Smirnov [ 2023-04-25 ] | |||||||||||||
|
psergei, please review the patch bb-10.4-mdev-31113. | |||||||||||||
| Comment by Sergei Petrunia [ 2023-04-25 ] | |||||||||||||
|
oleg.smirnov, please make Type_handler_string_result::sortlength() to assign suffix_length in all cases when Type_handler_string_result::make_sort_key() needs it. That way, the code will be structured better. | |||||||||||||
| Comment by Michael Widenius [ 2023-04-25 ] | |||||||||||||
|
An alternative, more future proof patch, is the following (in the same function): + if (!(sortorder= (SORT_FIELD*) my_malloc((fields->elements+1) * Add MY_ZEROFILL to MY_WME above. | |||||||||||||
| Comment by Oleg Smirnov [ 2023-04-25 ] | |||||||||||||
|
After discussion during an optimizer call we decided to proceed with the bzero() approach. | |||||||||||||
| Comment by Sergei Petrunia [ 2023-04-26 ] | |||||||||||||
|
Ok to push | |||||||||||||
| Comment by Oleg Smirnov [ 2023-04-28 ] | |||||||||||||
|
Pushed to 10.4 |