[MDEV-26992] Assertion `item->null_value' failed in Type_handler::Item_send_str upon query with UUID() Created: 2021-11-07  Updated: 2023-11-28

Status: Confirmed
Project: MariaDB Server
Component/s: Server
Affects Version/s: 10.7, 10.8, 10.9, 10.10, 10.11, 11.0
Fix Version/s: 10.11

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Sergei Golubchik
Resolution: Unresolved Votes: 0
Labels: None


 Description   

CREATE TABLE t (a INT) ENGINE=MyISAM;
INSERT INTO t VALUES (1);
 
# We need a non-strict mode
SET SQL_MODE= REPLACE(REPLACE(@@sql_mode,'STRICT_TRANS_TABLES',''),'STRICT_ALL_TABLES','');
 
SELECT UUID(), COUNT(*) FROM t WHERE RAND(1);
 
# Cleanup
DROP TABLE t;

bb-10.7-release 8bd21167d

mariadbd: /data/src/bb-10.7-release/sql/sql_type.cc:7460: bool Type_handler::Item_send_str(Item*, Protocol*, st_value*) const: Assertion `item->null_value' failed.
211108  1:39:53 [ERROR] mysqld got signal 6 ;
 
#7  0x00007f71a2d33f36 in __GI___assert_fail (assertion=0x56130ce47b80 "item->null_value", file=0x56130ce41f80 "/data/src/bb-10.7-release/sql/sql_type.cc", line=7460, function=0x56130ce47b00 "bool Type_handler::Item_send_str(Item*, Protocol*, st_value*) const") at assert.c:101
#8  0x000056130b19767a in Type_handler::Item_send_str (this=0x56130f7e6330 <FixedBinTypeBundle<UUID>::type_handler_fbt()::th>, item=0x6290000ea188, protocol=0x62b00007e870, buf=0x7f71998ac920) at /data/src/bb-10.7-release/sql/sql_type.cc:7460
#9  0x000056130c9a4bb0 in FixedBinTypeBundle<UUID>::Type_handler_fbt::Item_send (this=0x56130f7e6330 <FixedBinTypeBundle<UUID>::type_handler_fbt()::th>, item=0x6290000ea188, p=0x62b00007e870, buf=0x7f71998ac920) at /data/src/bb-10.7-release/sql/sql_type_fixedbin.h:590
#10 0x000056130a7ab03e in Item::send (this=0x6290000ea188, protocol=0x62b00007e870, buffer=0x7f71998ac920) at /data/src/bb-10.7-release/sql/item.h:1227
#11 0x000056130a863195 in Protocol::send_result_set_row (this=0x62b00007e870, row_items=0x6290000e8110) at /data/src/bb-10.7-release/sql/protocol.cc:1324
#12 0x000056130aa0bb9a in select_send::send_data (this=0x6290000e7ce8, items=...) at /data/src/bb-10.7-release/sql/sql_class.cc:3060
#13 0x000056130ad25c25 in select_result_sink::send_data_with_check (this=0x6290000e7ce8, items=..., u=0x62b000082690, sent=0) at /data/src/bb-10.7-release/sql/sql_class.h:5605
#14 0x000056130acd52f2 in do_select (join=0x6290000e7d18, procedure=0x0) at /data/src/bb-10.7-release/sql/sql_select.cc:20580
#15 0x000056130ac61de1 in JOIN::exec_inner (this=0x6290000e7d18) at /data/src/bb-10.7-release/sql/sql_select.cc:4735
#16 0x000056130ac5f2e6 in JOIN::exec (this=0x6290000e7d18) at /data/src/bb-10.7-release/sql/sql_select.cc:4513
#17 0x000056130ac6384f in mysql_select (thd=0x62b00007e288, tables=0x6290000e6b30, fields=..., conds=0x6290000e7328, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x6290000e7ce8, unit=0x62b000082690, select_lex=0x6290000e6370) at /data/src/bb-10.7-release/sql/sql_select.cc:4993
#18 0x000056130ac33d0b in handle_select (thd=0x62b00007e288, lex=0x62b0000825b8, result=0x6290000e7ce8, setup_tables_done_option=0) at /data/src/bb-10.7-release/sql/sql_select.cc:545
#19 0x000056130ab5a884 in execute_sqlcom_select (thd=0x62b00007e288, all_tables=0x6290000e6b30) at /data/src/bb-10.7-release/sql/sql_parse.cc:6253
#20 0x000056130ab4937b in mysql_execute_command (thd=0x62b00007e288, is_called_from_prepared_stmt=false) at /data/src/bb-10.7-release/sql/sql_parse.cc:3944
#21 0x000056130ab65b23 in mysql_parse (thd=0x62b00007e288, rawbuf=0x6290000e62a8 "SELECT UUID(), COUNT(*) FROM t WHERE RAND(1)", length=44, parser_state=0x7f71998ae9a0) at /data/src/bb-10.7-release/sql/sql_parse.cc:8028
#22 0x000056130ab3bc32 in dispatch_command (command=COM_QUERY, thd=0x62b00007e288, packet=0x62900025d289 "", packet_length=44, blocking=true) at /data/src/bb-10.7-release/sql/sql_parse.cc:1894
#23 0x000056130ab38956 in do_command (thd=0x62b00007e288, blocking=true) at /data/src/bb-10.7-release/sql/sql_parse.cc:1402
#24 0x000056130afd8f35 in do_handle_one_connection (connect=0x61100000a488, put_in_cache=true) at /data/src/bb-10.7-release/sql/sql_connect.cc:1418
#25 0x000056130afd87c1 in handle_one_connection (arg=0x61100000a348) at /data/src/bb-10.7-release/sql/sql_connect.cc:1312
#26 0x000056130bbcbd9f in pfs_spawn_thread (arg=0x618000005908) at /data/src/bb-10.7-release/storage/perfschema/pfs.cc:2201
#27 0x00007f71a324c609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#28 0x00007f71a2e1f293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Also reproducible with a subquery like (SELECT 1) sq instead of the table.

The failure appeared in 10.7 after this commit

commit b1fab9bf4e8a0d807c1076b6610c7208f40ca0c1
Author: Sergei Golubchik
Date:   Tue Sep 14 12:08:01 2021 +0200
 
    UUID() function should return UUID, not VARCHAR(36)

although possibly it just revealed a previously hidden issue. At least dependency on the non-strict mode existed before the patch above, although there was no assertion failure. I don't understand why the strict mode would affect this query, but it does.

With strict mode:

10.6

UUID()	COUNT(*)
NULL	0

With non-strict mode:

UUID()	COUNT(*)
	0



 Comments   
Comment by Elena Stepanova [ 2022-10-09 ]

For the search purposes, a different assertion fails with the same scenario but CREATE TABLE .. SELECT instead of SELECT:

CREATE TABLE t (a INT) ENGINE=MyISAM;
INSERT INTO t VALUES (1);
 
# We need a non-strict mode
SET SQL_MODE= REPLACE(REPLACE(@@sql_mode,'STRICT_TRANS_TABLES',''),'STRICT_ALL_TABLES','');
 
CREATE TABLE t2 AS SELECT UUID(), COUNT(*) FROM t WHERE RAND(1);
 
# Cleanup
DROP TABLE t, t2;

10.7 b6ebadaa

mariadbd: /data/src/10.7/sql/sql_type_fixedbin.h:1246: int FixedBinTypeBundle<FbtImpl>::Field_fbt::store_native(const Native&) [with FbtImpl = UUID]: Assertion `value.length() == FbtImpl::binary_length()' failed.
221009 23:32:53 [ERROR] mysqld got signal 6 ;
 
#7  0x00007f721e2bf662 in __GI___assert_fail (assertion=0x55c714469720 "value.length() == FbtImpl::binary_length()", file=0x55c7144679a0 "/data/src/10.7/sql/sql_type_fixedbin.h", line=1246, function=0x55c7144696a0 "int FixedBinTypeBundle<FbtImpl>::Field_fbt::store_native(const Native&) [with FbtImpl = UUID]") at assert.c:101
#8  0x000055c71323df25 in FixedBinTypeBundle<UUID>::Field_fbt::store_native (this=0x61900008c638, value=...) at /data/src/10.7/sql/sql_type_fixedbin.h:1246
#9  0x000055c713233b02 in FixedBinTypeBundle<UUID>::Type_handler_fbt::Item_save_in_field (this=0x55c71601cd90 <FixedBinTypeBundle<UUID>::type_handler_fbt()::th>, item=0x6290000ea0b0, field=0x61900008c638, no_conversions=false) at /data/src/10.7/sql/sql_type_fixedbin.h:602
#10 0x000055c711daa229 in Item::save_in_field (this=0x6290000ea0b0, field=0x61900008c638, no_conversions=false) at /data/src/10.7/sql/item.cc:6840
#11 0x000055c71323a3d0 in FixedBinTypeBundle<UUID>::Item_copy_fbt::save_in_field (this=0x6290000ea0b0, field=0x61900008c638, no_conversions=false) at /data/src/10.7/sql/sql_type_fixedbin.h:1757
#12 0x000055c711320a2f in fill_record (thd=0x62b00007e218, table=0x61900008c098, ptr=0x61900008c618, values=..., ignore_errors=true, use_value=false) at /data/src/10.7/sql/sql_base.cc:8933
#13 0x000055c711320ec7 in fill_record_n_invoke_before_triggers (thd=0x62b00007e218, table=0x61900008c098, ptr=0x61900008c610, values=..., ignore_errors=true, event=TRG_EVENT_INSERT) at /data/src/10.7/sql/sql_base.cc:8988
#14 0x000055c711403df0 in select_create::store_values (this=0x6290000e85e0, values=...) at /data/src/10.7/sql/sql_insert.cc:5015
#15 0x000055c7113faa0e in select_insert::send_data (this=0x6290000e85e0, values=...) at /data/src/10.7/sql/sql_insert.cc:4150
#16 0x000055c71167aab9 in select_result_sink::send_data_with_check (this=0x6290000e85e0, items=..., u=0x62b000082628, sent=0) at /data/src/10.7/sql/sql_class.h:5670
#17 0x000055c71162b8c0 in do_select (join=0x6290000e8730, procedure=0x0) at /data/src/10.7/sql/sql_select.cc:20802
#18 0x000055c7115b939b in JOIN::exec_inner (this=0x6290000e8730) at /data/src/10.7/sql/sql_select.cc:4782
#19 0x000055c7115b68af in JOIN::exec (this=0x6290000e8730) at /data/src/10.7/sql/sql_select.cc:4560
#20 0x000055c7115bacd0 in mysql_select (thd=0x62b00007e218, tables=0x6290000e7288, fields=..., conds=0x6290000e7aa8, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2201171004160, result=0x6290000e85e0, unit=0x62b000082628, select_lex=0x6290000e6ac8) at /data/src/10.7/sql/sql_select.cc:5040
#21 0x000055c71158b35d in handle_select (thd=0x62b00007e218, lex=0x62b000082550, result=0x6290000e85e0, setup_tables_done_option=0) at /data/src/10.7/sql/sql_select.cc:554
#22 0x000055c711797236 in Sql_cmd_create_table_like::execute (this=0x6290000e6320, thd=0x62b00007e218) at /data/src/10.7/sql/sql_table.cc:11914
#23 0x000055c7114b3f5b in mysql_execute_command (thd=0x62b00007e218, is_called_from_prepared_stmt=false) at /data/src/10.7/sql/sql_parse.cc:5989
#24 0x000055c7114c1131 in mysql_parse (thd=0x62b00007e218, rawbuf=0x6290000e6238 "CREATE TABLE t2 AS SELECT UUID(), COUNT(*) FROM t WHERE RAND(1)", length=63, parser_state=0x7f7214fdba90) at /data/src/10.7/sql/sql_parse.cc:8014
#25 0x000055c711497ad5 in dispatch_command (command=COM_QUERY, thd=0x62b00007e218, packet=0x62900025d219 "CREATE TABLE t2 AS SELECT UUID(), COUNT(*) FROM t WHERE RAND(1)", packet_length=63, blocking=true) at /data/src/10.7/sql/sql_parse.cc:1894
#26 0x000055c7114948a8 in do_command (thd=0x62b00007e218, blocking=true) at /data/src/10.7/sql/sql_parse.cc:1407
#27 0x000055c711926318 in do_handle_one_connection (connect=0x608000002538, put_in_cache=true) at /data/src/10.7/sql/sql_connect.cc:1416
#28 0x000055c711925cae in handle_one_connection (arg=0x6080000024b8) at /data/src/10.7/sql/sql_connect.cc:1318
#29 0x000055c7124d2fd2 in pfs_spawn_thread (arg=0x617000004d98) at /data/src/10.7/storage/perfschema/pfs.cc:2201
#30 0x00007f721e79bea7 in start_thread (arg=<optimized out>) at pthread_create.c:477
#31 0x00007f721e38aaef in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Comment by Alice Sherepa [ 2023-03-09 ]

also on 11.0:

mysqld: /11.0/sql/sql_type.cc:7459: bool Type_handler::Item_send_str(Item*, Protocol*, st_value*) const: Assertion `item->null_value' failed.
230309 16:50:04 [ERROR] mysqld got signal 6 ;
Server version: 11.0.2-MariaDB-debug-log source revision: 68542c6e5083a1e747696947662a76e42067ae5d
 
??:0(__assert_fail)[0x7f38cb0a2fd6]
sql/sql_type.cc:7460(Type_handler::Item_send_str(Item*, Protocol*, st_value*) const)[0x55bc0c3a7e18]
sql/sql_type_fixedbin.h:591(FixedBinTypeBundle<UUID>::Type_handler_fbt::Item_send(Item*, Protocol*, st_value*) const)[0x55bc0db9f12a]
sql/item.h:1236(Item::send(Protocol*, st_value*))[0x55bc0b947820]
sql/protocol.cc:1332(Protocol::send_result_set_row(List<Item>*))[0x55bc0ba06da3]
sql/sql_class.cc:3102(select_send::send_data(List<Item>&))[0x55bc0bbb57e8]
sql/sql_class.h:5748(select_result_sink::send_data_with_check(List<Item>&, st_select_lex_unit*, unsigned long long))[0x55bc0bee79c1]
sql/sql_select.cc:22515(do_select(JOIN*, Procedure*))[0x55bc0be95a96]
sql/sql_select.cc:4893(JOIN::exec_inner())[0x55bc0be16f59]
sql/sql_select.cc:4670(JOIN::exec())[0x55bc0be1430a]
sql/sql_select.cc:5151(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*))[0x55bc0be18a18]
sql/sql_select.cc:611(handle_select(THD*, LEX*, select_result*, unsigned long long))[0x55bc0bde8691]
sql/sql_parse.cc:6267(execute_sqlcom_select(THD*, TABLE_LIST*))[0x55bc0bd0a93d]
sql/sql_parse.cc:3949(mysql_execute_command(THD*, bool))[0x55bc0bcf91ec]
sql/sql_prepare.cc:5223(Prepared_statement::execute(String*, bool))[0x55bc0bdab156]
sql/sql_prepare.cc:4646(Prepared_statement::execute_loop(String*, bool, unsigned char*, unsigned char*))[0x55bc0bda6254]
sql/sql_prepare.cc:3578(mysql_stmt_execute_common(THD*, unsigned long, unsigned char*, unsigned char*, unsigned long, bool, bool))[0x55bc0bd9ed51]
sql/sql_prepare.cc:3349(mysqld_stmt_execute(THD*, char*, unsigned int))[0x55bc0bd9deb8]
sql/sql_parse.cc:1821(dispatch_command(enum_server_command, THD*, char*, unsigned int, bool))[0x55bc0bceb1e4]
sql/sql_parse.cc:1407(do_command(THD*, bool))[0x55bc0bce8652]
sql/sql_connect.cc:1416(do_handle_one_connection(CONNECT*, bool))[0x55bc0c1b5201]
sql/sql_connect.cc:1320(handle_one_connection)[0x55bc0c1b4b5e]
perfschema/pfs.cc:2203(pfs_spawn_thread)[0x55bc0cdcd6be]
nptl/pthread_create.c:478(start_thread)[0x7f38cb5bd609]

Generated at Thu Feb 08 09:49:30 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.