[MDEV-18899] Server crashes in Field::set_warning_truncated_wrong_value Created: 2019-03-12 Updated: 2020-08-25 Resolved: 2019-03-28 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Data types, Optimizer |
| Affects Version/s: | 10.2, 10.3, 10.4 |
| Fix Version/s: | 10.2.24, 10.3.14, 10.4.4 |
| Type: | Bug | Priority: | Critical |
| Reporter: | Alice Sherepa | Assignee: | Varun Gupta (Inactive) |
| Resolution: | Fixed | Votes: | 1 |
| Labels: | None | ||
| Issue Links: |
|
||||||||||||
| Description |
|
Reproducible on 10.2-10.4, with MyIsam/Innodb
Reproducible on non-debug build
|
| Comments |
| Comment by Alexander Barkov [ 2019-03-13 ] | ||||||||||||||||||||||||||||||||||
|
The crash happens in Field_varstring::store() which is called from here:
Field_varstring::store() tries to generate a warning, because the value in the column column_statistics.min_value is not well-formed: it has a hard limit of 255 bytes, so in this bug report on the position 255 it contains the first byte (of a two-byte character) without the second byte. The warning is generated here:
Notice, it tries to get the db and the table from from "table", however "table" is a NULL pointer here. table_field->read_stats->min_value is created here:
The above code clones a Field instance but does not set the "table" pointer for the cloned Field. So a solution to fix the crash would probably to copy table_field->table to min_value and max_value. However, it will fix only a part of the problem. Well-formedness problem It is generally wrong that any warnings are generated while copying from column_statistics.min_value. Note, column_statistics.min_value can be modified manually. So probably both #1 and #2 are needed. Contraction problemAlso, the underlying code should be checked for contraction compatibility. The code copying to column_statistics.min_value should make sure not to break contractions in the middle, otherwise max_value can be very far from the actual maximum value. For example, consider this data in combination with Czech collation:
'ch' is a separate letter which is sorted between 'h' and 'i': 'ch' should not be broken into parts when copying to column_statistics.min_value: For column_statistics.max_value, the copying code will be even harder: it should replace 'ch' to the character which immediately follows 'ch' in the collation, which is 'i'. | ||||||||||||||||||||||||||||||||||
| Comment by Alexander Barkov [ 2019-03-13 ] | ||||||||||||||||||||||||||||||||||
|
igor, please take over this bug. The problem resides in the statistical code. See the analysis above. | ||||||||||||||||||||||||||||||||||
| Comment by Varun Gupta (Inactive) [ 2019-03-19 ] | ||||||||||||||||||||||||||||||||||
|
Some imput from bar To fix the crash Another task would be to make sure that min and max values are set correctly, the suggestion is to fix this in 10.4 | ||||||||||||||||||||||||||||||||||
| Comment by Varun Gupta (Inactive) [ 2019-03-23 ] | ||||||||||||||||||||||||||||||||||
|
Patch | ||||||||||||||||||||||||||||||||||
| Comment by Varun Gupta (Inactive) [ 2019-03-23 ] | ||||||||||||||||||||||||||||||||||
|
Filed MDEV-19028 as a separate issue to address the contraction problem mentioned above |