You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
BUG#31360522 : >=5.6.36 SOME RANGE QUERIES STILL CRASH...
DESCRIPTION:
============
Certain range queries on a table with index prefixed
BLOB/TEXT columns could lead to a server exit.
ANALYSIS:
=========
While opening the table based on its table share, in
open_table_from_share(), we create a copy of the key_info
from TABLE_SHARE object to TABLE object. If the key is
prefixed, we allocate a new Field object, having its
field_length set to the prefix key length, and point the
table's matching key_part->field to this new Field object.
We skip creating the new Field object for prefixed BLOB
columns.
A secondary key is extended by adding primary key parts to
it if the primary key part does not exist in the secondary
key or the key part in the secondary key is a prefix of the
key field (add_pk_parts_to_sk()). The consequence of
skipping the creation of new Field object for prefixed BLOB
columns is that the key parts from the secondary key and
primary key will be pointing to the same Field object.
Later, while performing end-range scan, we check if the key
is within range (compare_key_in_buffer()). We change the
offsets of all the fields in the key range to make the
fields point to the record buffer
(move_key_field_offsets()). In case of BLOBs, we end up
moving the same field twice in move_key_field_offsets().
This leads to accessing out of bound memory while performing
key comparison.
FIX:
====
We allow creating new Field object even for BLOB columns in
open_table_from_share().
When a table with index prefixed BLOB columns is evicted
from Table cache, Field_blob objects are free'd by clearing
the Table's mem_root in closefrm(). However, since
Field_blob::value is allocated on the heap, a specific
cleanup to free the Field_blob objects has been added in
closefrm().
Note:
=====
This issue is not a regression but rather was exposed in
5.6.36 by the patch for Bug#23481444: OPTIMISER CALL
ROW_SEARCH_MVCC() AND READ THE INDEX APPLIED BY UNCOMMITTED
ROWS.
Change-Id: Ie0ecdb801b6cf81783c0cbd9a52d709fd3abdb30
0 commit comments