[MDEV-8779] mysqld got signal 11 in sql/opt_range_mrr.cc:100(step_down_to) Created: 2015-09-09 Updated: 2015-10-17 Resolved: 2015-09-21 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Optimizer |
| Affects Version/s: | 10.0, 10.1 |
| Fix Version/s: | 10.0.22, 10.1.8 |
| Type: | Bug | Priority: | Critical |
| Reporter: | Dan Vande More | Assignee: | Sergei Petrunia |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | eits | ||
| Environment: |
DISTRIB_ID=Ubuntu |
||
| Issue Links: |
|
||||||||||||
| Sprint: | 10.1.8-2 | ||||||||||||
| Description |
|
Using either tokudb or inndob, I have at query that can reliably trigger:
I have rebuilt the table several times, including rounds of optimize & analyze table, anayzle table persistent for all, etc.
|
| Comments |
| Comment by Elena Stepanova [ 2015-09-09 ] | ||||||||||||||||||||||||||||||||||||||||||
|
fimbulvetr The crash is reproducible on 10.0 and 10.1 with InnoDB or TokuDB; not reproducible with MyISAM.
I am getting a broken (or incomplete) stack trace both on 10.0 and 10.1, on two different machines, although it looks somewhat different. As I understand, it was broken for fimbulvetr as well. Examples:
Apart from fixing the crash, it is also very important to investigate what's going on with the stack trace. As discussed, assigning to svoj for a preliminary analysis. | ||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergey Vojtovich [ 2015-09-11 ] | ||||||||||||||||||||||||||||||||||||||||||
|
In create_key_parts_for_pseudo_indexes() we remember field->key_length() for every used field. For "`n` varchar(2048) NOT NULL" we get 6144 (2048 * mbmaxlen of UTF-8, which is 3). Later we do step_down_to()/SEL_ARG::store_max(), which does memcpy(*max_key,max_value,length). IIUC max_key was allocated as: RANGE_OPT_PARAM::max_key[MAX_KEY_LENGTH+MAX_FIELD_WIDTH], in other words 3072 + 255 * 3 + 1= 3838. So we actually do memcpy(max_key[3838], max_value, 6144). This statement effectively breaks stack trace, crash happens later as an outcome of this overwrite. | ||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2015-09-20 ] | ||||||||||||||||||||||||||||||||||||||||||
|
I was wondering if partition pruning is affected by this problem. It turns out, no. partition_info::check_partition_field_length() disallows creation of partitioning schemes which have partitioning columns occupy more than MAX_KEY_LENGTH when encoded with KeyTupleFormat. | ||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2015-09-20 ] | ||||||||||||||||||||||||||||||||||||||||||
|
Looking through opt_range.cc code, RANGE_OPT_PARAM::min_key and max-key seem to be the only places where the code implies that key images do not exceed MAX_KEY_LENGTH in size. The steps are:
Buffer overrun seems to only be possible in #3. | ||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2015-09-20 ] | ||||||||||||||||||||||||||||||||||||||||||
|
http://lists.askmonty.org/pipermail/commits/2015-September/008419.html | ||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2015-09-21 ] | ||||||||||||||||||||||||||||||||||||||||||
|
Following svoj 's advice, debugged a few queries. new alloc_root calls do not cause calls to malloc() | ||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2015-09-22 ] | ||||||||||||||||||||||||||||||||||||||||||
|
The patch had a typo which caused |