|
The reported line is
2988
|
// length stored in lowendian form
|
2989
|
store_key_part_length(data_length + suffix_length, to, length_bytes);
|
2990
|
to+= length_bytes;
|
2991
|
// copying data length bytes to the buffer
|
2992
|
memcpy(to, (uchar*)str->ptr(), data_length);
|
2993
|
to+= data_length;
|
Apparently, str->ptr() is NULL here. It is an argument to
2974
|
uint
|
2975
|
SORT_FIELD_ATTR::pack_sort_string(uchar *to, const Binary_string *str,
|
2976
|
CHARSET_INFO *cs) const
|
2977
|
{
|
which is invoked as
2609
|
}
|
2610
|
return sort_field->pack_sort_string(to, res, cs);
|
from
2575
|
uint
|
2576
|
Type_handler_string_result::make_packed_sort_key_part(uchar *to, Item *item,
|
2577
|
const SORT_FIELD_ATTR *sort_field,
|
2578
|
Sort_param *param) const
|
2579
|
{
|
2580
|
CHARSET_INFO *cs= item->collation.collation;
|
2581
|
bool maybe_null= item->maybe_null();
|
2582
|
|
2583
|
if (maybe_null)
|
2584
|
*to++= 1;
|
2585
|
|
2586
|
Binary_string *res= item->str_result(¶m->tmp_buffer);
|
2587
|
if (!res)
|
2588
|
{
|
That is here, res != NULL, but res->ptr() is NULL. As far as I understand, this isn't normal, val_str() and str_result() are expected to return either NULL or a non-NULL string.
|
|
Improved testcase, updated test report:
SELECT * FROM mysql.user ORDER BY authentication_string;
|
Leads to:
|
10.9.0 161fd2d29cc2f8390fa3bf7e739c52bc8d5c39df (Optimized, UBASAN)
|
/test/10.9_opt_san/sql/filesort.cc:2997:9: runtime error: null pointer passed as argument 2, which is declared to never be null
|
|
10.9.0 161fd2d29cc2f8390fa3bf7e739c52bc8d5c39df (Optimized, UBASAN)
|
#0 0x558329b466c0 in SORT_FIELD_ATTR::pack_sort_string(unsigned char*, Binary_string const*, charset_info_st const*) const /test/10.9_opt_san/sql/filesort.cc:2997
|
#1 0x55832bd2bbfb in make_packed_sortkey /test/10.9_opt_san/sql/filesort.cc:3094
|
#2 0x55832bd2bbfb in make_sortkey /test/10.9_opt_san/sql/filesort.cc:1362
|
#3 0x55832bd39387 in find_all_keys /test/10.9_opt_san/sql/filesort.cc:978
|
#4 0x55832bd39387 in filesort(THD*, TABLE*, Filesort*, Filesort_tracker*, JOIN*, unsigned long long) /test/10.9_opt_san/sql/filesort.cc:357
|
#5 0x55832ab58099 in create_sort_index(THD*, JOIN*, st_join_table*, Filesort*) /test/10.9_opt_san/sql/sql_select.cc:24425
|
#6 0x55832ab59c4f in st_join_table::sort_table() /test/10.9_opt_san/sql/sql_select.cc:22106
|
#7 0x55832ab5a29c in join_init_read_record(st_join_table*) /test/10.9_opt_san/sql/sql_select.cc:22045
|
#8 0x55832aac67a5 in sub_select(JOIN*, st_join_table*, bool) /test/10.9_opt_san/sql/sql_select.cc:21092
|
#9 0x55832ac72123 in do_select /test/10.9_opt_san/sql/sql_select.cc:20640
|
#10 0x55832ac72123 in JOIN::exec_inner() /test/10.9_opt_san/sql/sql_select.cc:4749
|
#11 0x55832ac769f9 in JOIN::exec() /test/10.9_opt_san/sql/sql_select.cc:4527
|
#12 0x55832ac64b61 in mysql_select(THD*, TABLE_LIST*, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*) /test/10.9_opt_san/sql/sql_select.cc:5007
|
#13 0x55832ac68a73 in handle_select(THD*, LEX*, select_result*, unsigned long) /test/10.9_opt_san/sql/sql_select.cc:543
|
#14 0x55832a87fcdf in execute_sqlcom_select /test/10.9_opt_san/sql/sql_parse.cc:6268
|
#15 0x55832a8bf88b in mysql_execute_command(THD*, bool) /test/10.9_opt_san/sql/sql_parse.cc:3959
|
#16 0x55832a84f0a8 in mysql_parse(THD*, char*, unsigned int, Parser_state*) /test/10.9_opt_san/sql/sql_parse.cc:8043
|
#17 0x55832a8a5439 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool) /test/10.9_opt_san/sql/sql_parse.cc:1910
|
#18 0x55832a8b0c92 in do_command(THD*, bool) /test/10.9_opt_san/sql/sql_parse.cc:1407
|
#19 0x55832b19bd3d in do_handle_one_connection(CONNECT*, bool) /test/10.9_opt_san/sql/sql_connect.cc:1418
|
#20 0x55832b19e834 in handle_one_connection /test/10.9_opt_san/sql/sql_connect.cc:1312
|
#21 0x55832d29c1f9 in pfs_spawn_thread /test/10.9_opt_san/storage/perfschema/pfs.cc:2201
|
#22 0x1464cbeee608 in start_thread /build/glibc-sMfBJT/glibc-2.31/nptl/pthread_create.c:477
|
#23 0x1464cb163162 in __clone (/lib/x86_64-linux-gnu/libc.so.6+0x11f162)
|
|
10.9.0 161fd2d29cc2f8390fa3bf7e739c52bc8d5c39df (Debug, UBASAN)
|
/test/10.9_dbg_san/sql/filesort.cc:2997:9: runtime error: null pointer passed as argument 2, which is declared to never be null
|
|
10.9.0 161fd2d29cc2f8390fa3bf7e739c52bc8d5c39df (Debug, UBASAN)
|
#0 0x564c17191fc0 in SORT_FIELD_ATTR::pack_sort_string(unsigned char*, Binary_string const*, charset_info_st const*) const /test/10.9_dbg_san/sql/filesort.cc:2997
|
#1 0x564c17193247 in Type_handler_string_result::make_packed_sort_key_part(unsigned char*, Item*, SORT_FIELD_ATTR const*, Sort_param*) const /test/10.9_dbg_san/sql/filesort.cc:2615
|
#2 0x564c171877f0 in make_packed_sortkey /test/10.9_dbg_san/sql/filesort.cc:3094
|
#3 0x564c171877f0 in make_sortkey /test/10.9_dbg_san/sql/filesort.cc:1362
|
#4 0x564c1719d972 in find_all_keys /test/10.9_dbg_san/sql/filesort.cc:978
|
#5 0x564c1719d972 in filesort(THD*, TABLE*, Filesort*, Filesort_tracker*, JOIN*, unsigned long long) /test/10.9_dbg_san/sql/filesort.cc:357
|
#6 0x564c15ca6a0d in create_sort_index(THD*, JOIN*, st_join_table*, Filesort*) /test/10.9_dbg_san/sql/sql_select.cc:24425
|
#7 0x564c15ca8414 in st_join_table::sort_table() /test/10.9_dbg_san/sql/sql_select.cc:22106
|
#8 0x564c15ca8ec4 in join_init_read_record(st_join_table*) /test/10.9_dbg_san/sql/sql_select.cc:22045
|
#9 0x564c15be8c16 in sub_select(JOIN*, st_join_table*, bool) /test/10.9_dbg_san/sql/sql_select.cc:21092
|
#10 0x564c15dbb362 in do_select /test/10.9_dbg_san/sql/sql_select.cc:20640
|
#11 0x564c15dbb362 in JOIN::exec_inner() /test/10.9_dbg_san/sql/sql_select.cc:4749
|
#12 0x564c15dbcc94 in JOIN::exec() /test/10.9_dbg_san/sql/sql_select.cc:4527
|
#13 0x564c15dac58b in mysql_select(THD*, TABLE_LIST*, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*) /test/10.9_dbg_san/sql/sql_select.cc:5007
|
#14 0x564c15dadef0 in handle_select(THD*, LEX*, select_result*, unsigned long) /test/10.9_dbg_san/sql/sql_select.cc:543
|
#15 0x564c1591afc2 in execute_sqlcom_select /test/10.9_dbg_san/sql/sql_parse.cc:6268
|
#16 0x564c15980216 in mysql_execute_command(THD*, bool) /test/10.9_dbg_san/sql/sql_parse.cc:3959
|
#17 0x564c158e2728 in mysql_parse(THD*, char*, unsigned int, Parser_state*) /test/10.9_dbg_san/sql/sql_parse.cc:8043
|
#18 0x564c1595844e in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool) /test/10.9_dbg_san/sql/sql_parse.cc:1910
|
#19 0x564c1596efa9 in do_command(THD*, bool) /test/10.9_dbg_san/sql/sql_parse.cc:1407
|
#20 0x564c1643bc4b in do_handle_one_connection(CONNECT*, bool) /test/10.9_dbg_san/sql/sql_connect.cc:1418
|
#21 0x564c1643eae5 in handle_one_connection /test/10.9_dbg_san/sql/sql_connect.cc:1312
|
#22 0x564c18997c62 in pfs_spawn_thread /test/10.9_dbg_san/storage/perfschema/pfs.cc:2201
|
#23 0x148a6f19c608 in start_thread /build/glibc-sMfBJT/glibc-2.31/nptl/pthread_create.c:477
|
#24 0x148a6e411162 in __clone (/lib/x86_64-linux-gnu/libc.so.6+0x11f162)
|
Setup:
Compiled with GCC >=7.5.0 (I use GCC 9.4.0) and:
|
-DWITH_ASAN=ON -DWITH_ASAN_SCOPE=ON -DWITH_UBSAN=ON -DWITH_RAPID=OFF -DWSREP_LIB_WITH_ASAN=ON
|
Set before execution:
|
export UBSAN_OPTIONS=print_stacktrace=1
|
Bug confirmed present in:
MariaDB: 10.5.16 (dbg), 10.5.16 (opt), 10.6.8 (dbg), 10.6.8 (opt), 10.7.4 (dbg), 10.7.4 (opt), 10.8.3 (dbg), 10.8.3 (opt), 10.9.0 (dbg), 10.9.0 (opt)
Bug (or feature/syntax) confirmed not present in:
MariaDB: 10.2.44 (dbg), 10.2.44 (opt), 10.3.35 (dbg), 10.3.35 (opt), 10.4.25 (dbg), 10.4.25 (opt)
UniqueID's seen:
UBSAN|null pointer passed as argument 2, which is declared to never be null|sql/filesort.cc|SORT_FIELD_ATTR::pack_sort_string|Type_handler_string_result::make_packed_sort_key_part|make_packed_sortkey|make_sortkey
|
UBSAN|null pointer passed as argument 2, which is declared to never be null|sql/filesort.cc|SORT_FIELD_ATTR::pack_sort_string|make_packed_sortkey|make_sortkey|find_all_keys
|
|