[MDEV-19776] Assertion `to_len >= 8' failed in convert_to_printable with optimizer trace enabled Created: 2019-06-16  Updated: 2019-08-14  Resolved: 2019-06-20

Status: Closed
Project: MariaDB Server
Component/s: Optimizer
Affects Version/s: 10.4
Fix Version/s: 10.4.7

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Varun Gupta (Inactive)
Resolution: Fixed Votes: 0
Labels: affects-tests

Issue Links:
Relates
relates to MDEV-20349 Assertion `to_len >= 8' failed in con... Closed

 Description   

CREATE TABLE t1 (f VARBINARY(16) NOT NULL, KEY(f));
INSERT INTO t1 VALUES ('a'),('b'); # Optional
SET optimizer_trace = 'enabled=on';
DELETE FROM t1 WHERE f = 'x';
 
# Cleanup
DROP TABLE t1;

10.4 bff7cf9d

mysqld: /data/src/10.4/sql/sql_string.cc:1154: uint convert_to_printable(char*, size_t, const char*, size_t, CHARSET_INFO*, size_t): Assertion `to_len >= 8' failed.
190617  1:35:47 [ERROR] mysqld got signal 6 ;
 
#7  0x00007fc2ef799f12 in __GI___assert_fail (assertion=0x56227fce69f0 "to_len >= 8", file=0x56227fce6820 "/data/src/10.4/sql/sql_string.cc", line=1154, function=0x56227fce6d40 <convert_to_printable(char*, unsigned long, char const*, unsigned long, charset_info_st const*, unsigned long)::__PRETTY_FUNCTION__> "uint convert_to_printable(char*, size_t, const char*, size_t, CHARSET_INFO*, size_t)") at assert.c:101
#8  0x000056227f194813 in convert_to_printable (to=0x7fc2e996898e "", to_len=5, from=0x7fc2d813a581 "x", from_len=1, from_cs=0x56228077c840 <my_charset_bin>, nbytes=0) at /data/src/10.4/sql/sql_string.cc:1154
#9  0x000056227f194a1b in String::append_semi_hex (this=0x7fc2e9968970, s=0x7fc2d813a581 "x", len=1, cs=0x56228077c840 <my_charset_bin>) at /data/src/10.4/sql/sql_string.cc:1206
#10 0x000056227f3ea826 in Field::print_key_value_binary (this=0x7fc2d813a5c0, out=0x7fc2e9968970, key=0x7fc2d813a581 "x", length=1) at /data/src/10.4/sql/field.cc:11298
#11 0x000056227f3ea708 in Field_varstring::print_key_value (this=0x7fc2d813a5c0, out=0x7fc2e9968970, length=16) at /data/src/10.4/sql/field.cc:11277
#12 0x000056227f58e46e in print_key_value (out=0x7fc2e99690a0, key_part=0x7fc2d813a768, key=0x7fc2d8068d90 "\001", used_length=18) at /data/src/10.4/sql/opt_range.cc:15861
#13 0x000056227f58dee3 in print_range (out=0x7fc2e99690a0, key_part=0x7fc2d813a768, range=0x7fc2e9968b30, n_key_parts=1) at /data/src/10.4/sql/opt_range.cc:15745
#14 0x000056227f58e1ad in trace_ranges (range_trace=0x7fc2e9969250, param=0x7fc2e9969500, idx=0, keypart=0x7fc2d8068e58, key_parts=0x7fc2d813a768) at /data/src/10.4/sql/opt_range.cc:15804
#15 0x000056227f57906b in get_key_scans_params (param=0x7fc2e9969500, tree=0x7fc2d8068dc0, index_read_must_be_used=false, update_tbl_stats=true, read_time=4.509765625) at /data/src/10.4/sql/opt_range.cc:7386
#16 0x000056227f56dc1d in SQL_SELECT::test_quick_select (this=0x7fc2d8013e60, thd=0x7fc2d8000b00, keys_to_use=..., prev_tables=0, limit=18446744073709551615, force_quick_range=false, ordered_output=false, remove_false_parts_of_where=false, only_single_index_range_scan=false) at /data/src/10.4/sql/opt_range.cc:2895
#17 0x000056227f1d52bc in SQL_SELECT::check_quick (this=0x7fc2d8013e60, thd=0x7fc2d8000b00, force_quick_range=false, limit=18446744073709551615) at /data/src/10.4/sql/opt_range.h:1653
#18 0x000056227f5b5102 in mysql_delete (thd=0x7fc2d8000b00, table_list=0x7fc2d80131f0, conds=0x7fc2d8013a50, order_list=0x7fc2d80054a0, limit=18446744073709551615, options=0, result=0x0) at /data/src/10.4/sql/sql_delete.cc:543
#19 0x000056227f0caa83 in mysql_execute_command (thd=0x7fc2d8000b00) at /data/src/10.4/sql/sql_parse.cc:4713
#20 0x000056227f0d5ab1 in mysql_parse (thd=0x7fc2d8000b00, rawbuf=0x7fc2d8013108 "DELETE FROM t1 WHERE f = 'x'", length=28, parser_state=0x7fc2e996b180, is_com_multi=false, is_next_command=false) at /data/src/10.4/sql/sql_parse.cc:7887
#21 0x000056227f0c1dcd in dispatch_command (command=COM_QUERY, thd=0x7fc2d8000b00, packet=0x7fc2d8008311 "DELETE FROM t1 WHERE f = 'x'", packet_length=28, is_com_multi=false, is_next_command=false) at /data/src/10.4/sql/sql_parse.cc:1829
#22 0x000056227f0c058b in do_command (thd=0x7fc2d8000b00) at /data/src/10.4/sql/sql_parse.cc:1362
#23 0x000056227f23971b in do_handle_one_connection (connect=0x56228301c010) at /data/src/10.4/sql/sql_connect.cc:1403
#24 0x000056227f23947f in handle_one_connection (arg=0x56228301c010) at /data/src/10.4/sql/sql_connect.cc:1306
#25 0x000056227fb63d73 in pfs_spawn_thread (arg=0x5622830513a0) at /data/src/10.4/storage/perfschema/pfs.cc:1862
#26 0x00007fc2f130e4a4 in start_thread (arg=0x7fc2e996c700) at pthread_create.c:456
#27 0x00007fc2ef856d0f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:97

Reproducible with InnoDB, MyISAM, Aria.
No obvious problem on a non-debug build.



 Comments   
Comment by Varun Gupta (Inactive) [ 2019-06-18 ]

convert_to_printable function has

  /* needs at least 8 bytes for '\xXX...' and zero byte */
  DBUG_ASSERT(to_len >= 8);

So we need space for atleast 8 characters, if there is less space provided, then we append "...". This would not happen for the case of optimizer trace. To fix the assert failure what we can do is to send length of atleast 8 characters.

Comment by Varun Gupta (Inactive) [ 2019-06-18 ]

Patch
http://lists.askmonty.org/pipermail/commits/2019-June/013859.html

Comment by Alexander Barkov [ 2019-06-18 ]

OK to push.

Generated at Thu Feb 08 08:54:17 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.