[MDEV-17971] Server crash in Field_iterator_table::set or Assertion `table_ref->table || table_ref->view' failed in Field_iterator_table_ref::set_field_iterator Created: 2018-12-11  Updated: 2023-10-09

Status: Confirmed
Project: MariaDB Server
Component/s: None
Affects Version/s: 10.3, 10.4
Fix Version/s: 10.4

Type: Bug Priority: Minor
Reporter: Alice Sherepa Assignee: Igor Babaev
Resolution: Unresolved Votes: 0
Labels: None

Issue Links:
Relates
relates to MDEV-16992 Assertion `table_ref->table || table_... Closed

 Description   

create table t1 (v1 varchar(1));
insert into t1 values ('a'),('b'),('c');
 
DELIMITER ##;
create  procedure sp () 
begin 
select 1 from t1 group by left((values(v1)), null) ; 
end ;##
 
DELIMITER ;##
--error 4100
call sp;
call sp;

10.3 705fd4e94304215454ef7c35

mysqld: /git/10.3/sql/table.cc:6040: void Field_iterator_table_ref::set_field_iterator(): Assertion `table_ref->table || table_ref->view' failed.
 
stdlib/abort.c:91(__GI_abort)[0x7fe330d9802a]
assert/assert.c:92(__assert_fail_base)[0x7fe330d8ebd7]
/lib/x86_64-linux-gnu/libc.so.6(+0x2dc82)[0x7fe330d8ec82]
sql/table.cc:6041(Field_iterator_table_ref::set_field_iterator())[0x5557a0958326]
sql/table.cc:6058(Field_iterator_table_ref::set(TABLE_LIST*))[0x5557a095872f]
sql/sql_base.cc:7854(insert_fields(THD*, Name_resolution_context*, char const*, char const*, List_iterator<Item>*, bool, unsigned int*))[0x5557a0582c79]
sql/sql_base.cc:7309(setup_wild(THD*, TABLE_LIST*, List<Item>&, List<Item>*, unsigned int, unsigned int*))[0x5557a057f626]
sql/sql_select.cc:1091(JOIN::prepare(TABLE_LIST*, unsigned int, Item*, unsigned int, st_order*, bool, st_order*, Item*, st_order*, st_select_lex*, st_select_lex_unit*))[0x5557a074466e]
sql/item_subselect.cc:3667(subselect_single_select_engine::prepare(THD*))[0x5557a0f8e1fe]
sql/item_subselect.cc:276(Item_subselect::fix_fields(THD*, Item**))[0x5557a0f6e307]
sql/item.h:825(Item::fix_fields_if_needed(THD*, Item**))[0x5557a048c445]
sql/item_func.cc:363(Item_func::fix_fields(THD*, Item**))[0x5557a0eb27fd]
sql/item_strfunc.cc:106(Item_str_func::fix_fields(THD*, Item**))[0x5557a0f2f1f9]
sql/item.h:825(Item::fix_fields_if_needed(THD*, Item**))[0x5557a048c445]
sql/item.h:828(Item::fix_fields_if_needed_for_scalar(THD*, Item**))[0x5557a048c473]
sql/item.h:837(Item::fix_fields_if_needed_for_order_by(THD*, Item**))[0x5557a0800b11]
sql/sql_select.cc:23141(find_order_in_list(THD*, Bounds_checked_array<Item*>, TABLE_LIST*, st_order*, List<Item>&, List<Item>&, bool, bool, bool))[0x5557a07de152]
sql/sql_select.cc:23244(setup_group(THD*, Bounds_checked_array<Item*>, TABLE_LIST*, List<Item>&, List<Item>&, st_order*, bool*, bool))[0x5557a07de909]
sql/sql_select.cc:669(setup_without_group(THD*, Bounds_checked_array<Item*>, TABLE_LIST*, List<TABLE_LIST>&, List<Item>&, List<Item>&, Item**, st_order*, st_order*, List<Window_spec>&, List<Item_window_func>&, bool*, unsigned int*))[0x5557a0740288]
sql/sql_select.cc:1107(JOIN::prepare(TABLE_LIST*, unsigned int, Item*, unsigned int, st_order*, bool, st_order*, Item*, st_order*, st_select_lex*, st_select_lex_unit*))[0x5557a0744c48]
sql/sql_select.cc:4217(mysql_select(THD*, TABLE_LIST*, unsigned int, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*))[0x5557a0762b58]
sql/sql_select.cc:385(handle_select(THD*, LEX*, select_result*, unsigned long))[0x5557a073e11f]
sql/sql_parse.cc:6547(execute_sqlcom_select(THD*, TABLE_LIST*))[0x5557a06c48a3]
sql/sql_parse.cc:3768(mysql_execute_command(THD*))[0x5557a06b2ffd]
sql/sp_head.cc:3594(sp_instr_stmt::exec_core(THD*, unsigned int*))[0x5557a04d535c]
sql/sp_head.cc:3322(sp_lex_keeper::reset_lex_and_exec_core(THD*, unsigned int*, bool, sp_instr*))[0x5557a04d3c8f]
sql/sp_head.cc:3500(sp_instr_stmt::execute(THD*, unsigned int*))[0x5557a04d4b44]
sql/sp_head.cc:1354(sp_head::execute(THD*, bool))[0x5557a04c7f13]
sql/sp_head.cc:2294(sp_head::execute_procedure(THD*, List<Item>*))[0x5557a04cd0d5]
sql/sql_parse.cc:2950(do_execute_sp(THD*, sp_head*))[0x5557a06adaff]
sql/sql_parse.cc:3190(Sql_cmd_call::execute(THD*))[0x5557a06af542]
sql/sql_parse.cc:6284(mysql_execute_command(THD*))[0x5557a06c2639]
sql/sql_parse.cc:8091(mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool))[0x5557a06cd2bf]
sql/sql_parse.cc:1852(dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool))[0x5557a06a7d82]
sql/sql_parse.cc:1395(do_command(THD*))[0x5557a06a4f1a]
sql/sql_connect.cc:1402(do_handle_one_connection(CONNECT*))[0x5557a09f7937]
sql/sql_connect.cc:1309(handle_one_connection)[0x5557a09f7314]
perfschema/pfs.cc:1864(pfs_spawn_thread)[0x5557a1d1e727]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x76ba)[0x7fe3319d36ba]
x86_64/clone.S:111(clone)[0x7fe330e6841d]
 
Query (0x62500016f988): select 1 from t1 group by left((values(v1)), null)



 Comments   
Comment by Elena Stepanova [ 2018-12-11 ]

It also causes a crash on a non-debug build:

10.3 non-debug ac31ff6275

#2  <signal handler called>
#3  0x000055e3b8c5ceb7 in Field_iterator_table::set (this=0x7f3a19785810, table=0x7f3a08072b40) at /data/src/10.3/sql/table.h:2672
#4  0x000055e3b8b53245 in insert_fields (thd=0x7f3a080009a8, context=<optimized out>, db_name=0x0, table_name=0x0, it=0x7f3a19785bd0, any_privileges=false, hidden_bit_fields=0x7f3a08071d30) at /data/src/10.3/sql/sql_base.cc:7853
#5  0x000055e3b8b5357f in setup_wild (thd=0x7f3a080009a8, tables=0x7f3a08072b40, fields=..., sum_func_list=0x7f3a080a8748, wild_num=1, hidden_bit_fields=0x0) at /data/src/10.3/sql/sql_base.cc:7309
#6  0x000055e3b8bec9d4 in JOIN::prepare (this=0x7f3a080a8428, tables_init=0x7f3a08072b40, wild_num=1, conds_init=0x0, og_num=0, order_init=0x0, skip_order_by=false, group_init=0x0, having_init=0x0, proc_param_init=0x0, select_lex_arg=0x7f3a08071a50, unit_arg=0x7f3a0806f048) at /data/src/10.3/sql/sql_select.cc:1092
#7  0x000055e3b8e0b9f9 in subselect_single_select_engine::prepare (this=0x7f3a0806d610, thd=0x7f3a080009a8) at /data/src/10.3/sql/item_subselect.cc:3677
#8  0x000055e3b8e0adc8 in Item_subselect::fix_fields (this=0x7f3a0806d488, thd_param=<optimized out>, ref=0x7f3a0806d768) at /data/src/10.3/sql/item_subselect.cc:276
#9  0x000055e3b8dcee2f in fix_fields_if_needed (ref=0x7f3a0806d768, thd=0x7f3a080009a8, this=0x7f3a0806d488) at /data/src/10.3/sql/item.h:824
#10 Item_func::fix_fields (this=this@entry=0x7f3a0806d6d8, thd=thd@entry=0x7f3a080009a8, ref=<optimized out>) at /data/src/10.3/sql/item_func.cc:363
#11 0x000055e3b8df05c1 in Item_str_func::fix_fields (this=0x7f3a0806d6d8, thd=0x7f3a080009a8, ref=<optimized out>) at /data/src/10.3/sql/item_strfunc.cc:106
#12 0x000055e3b8bcce54 in fix_fields_if_needed (ref=<optimized out>, thd=<optimized out>, this=<optimized out>) at /data/src/10.3/sql/item.h:824
#13 fix_fields_if_needed_for_scalar (ref=<optimized out>, thd=<optimized out>, this=<optimized out>) at /data/src/10.3/sql/item.h:828
#14 fix_fields_if_needed_for_order_by (ref=<optimized out>, thd=<optimized out>, this=<optimized out>) at /data/src/10.3/sql/item.h:836
#15 find_order_in_list (thd=0x7f3a080009a8, ref_pointer_array=..., tables=0x0, tables@entry=0x7f3a0806c878, order=0x7f3a0806d7b8, fields=..., all_fields=..., is_group_field=true, add_to_all_fields=true, from_window_spec=false) at /data/src/10.3/sql/sql_select.cc:23141
#16 0x000055e3b8be9b2a in setup_group (thd=0x7f3a080009a8, ref_pointer_array=..., tables=0x7f3a0806c878, fields=..., all_fields=..., order=0x7f3a0806d7b8, hidden_group_fields=0x7f3a080a8197, from_window_spec=false) at /data/src/10.3/sql/sql_select.cc:23244
#17 0x000055e3b8bece29 in setup_without_group (reserved=<optimized out>, hidden_group_fields=<optimized out>, win_funcs=..., win_specs=..., group=<optimized out>, order=<optimized out>, conds=<optimized out>, all_fields=..., fields=..., leaves=..., tables=<optimized out>, ref_pointer_array=..., thd=<optimized out>) at /data/src/10.3/sql/sql_select.cc:670
#18 JOIN::prepare (this=0x7f3a080a7eb0, tables_init=0x7f3a08072b40, wild_num=0, conds_init=0x0, og_num=0, order_init=0x0, skip_order_by=false, group_init=0x0, having_init=0x0, proc_param_init=0x0, select_lex_arg=0x7f3a0806e148, unit_arg=0x7f3a0806d9d8) at /data/src/10.3/sql/sql_select.cc:1113
#19 0x000055e3b8bfd534 in mysql_select (thd=thd@entry=0x7f3a080009a8, tables=0x7f3a0806c878, wild_num=0, fields=..., conds=0x0, og_num=1, order=0x0, group=0x7f3a0806d7b8, having=0x0, proc_param=0x0, select_options=2147749632, result=0x7f3a080a7e88, unit=0x7f3a0806d9d8, select_lex=0x7f3a0806e148) at /data/src/10.3/sql/sql_select.cc:4217
#20 0x000055e3b8bfd727 in handle_select (thd=thd@entry=0x7f3a080009a8, lex=lex@entry=0x7f3a0806d910, result=result@entry=0x7f3a080a7e88, setup_tables_done_option=setup_tables_done_option@entry=0) at /data/src/10.3/sql/sql_select.cc:385
#21 0x000055e3b8ac6534 in execute_sqlcom_select (thd=0x7f3a080009a8, all_tables=0x7f3a0806c878) at /data/src/10.3/sql/sql_parse.cc:6547
#22 0x000055e3b8ba75b3 in mysql_execute_command (thd=0x7f3a080009a8) at /data/src/10.3/sql/sql_parse.cc:3768
#23 0x000055e3b8b1b414 in sp_instr_stmt::exec_core (this=0x7f3a0806d810, thd=<optimized out>, nextp=0x7f3a19788434) at /data/src/10.3/sql/sp_head.cc:3594
#24 0x000055e3b8b22473 in sp_lex_keeper::reset_lex_and_exec_core (this=this@entry=0x7f3a0806d858, thd=thd@entry=0x7f3a080009a8, nextp=nextp@entry=0x7f3a19788434, open_tables=open_tables@entry=false, instr=instr@entry=0x7f3a0806d810) at /data/src/10.3/sql/sp_head.cc:3322
#25 0x000055e3b8b22dc1 in sp_instr_stmt::execute (this=0x7f3a0806d810, thd=0x7f3a080009a8, nextp=0x7f3a19788434) at /data/src/10.3/sql/sp_head.cc:3500
#26 0x000055e3b8b1e97b in sp_head::execute (this=this@entry=0x7f3a0806b8e0, thd=thd@entry=0x7f3a080009a8, merge_da_on_success=merge_da_on_success@entry=true) at /data/src/10.3/sql/sp_head.cc:1354
#27 0x000055e3b8b1fc0e in sp_head::execute_procedure (this=0x7f3a0806b8e0, thd=0x7f3a080009a8, args=0x7f3a08005438) at /data/src/10.3/sql/sp_head.cc:2294
#28 0x000055e3b8b9c00d in do_execute_sp (thd=0x7f3a080009a8, sp=0x7f3a19785810, sp@entry=0x7f3a080009a8) at /data/src/10.3/sql/sql_parse.cc:2950
#29 0x000055e3b8b9d486 in Sql_cmd_call::execute (this=this@entry=0x7f3a08011738, thd=thd@entry=0x7f3a080009a8) at /data/src/10.3/sql/sql_parse.cc:3190
#30 0x000055e3b8b9dd17 in Sql_cmd_call::execute (this=0x7f3a08011738, thd=0x7f3a080009a8) at /data/src/10.3/sql/sql_parse.cc:3144
#31 0x000055e3b8ba3587 in mysql_execute_command (thd=0x7f3a080009a8) at /data/src/10.3/sql/sql_parse.cc:6284
#32 0x000055e3b8ba9c29 in mysql_parse (thd=0x7f3a080009a8, rawbuf=<optimized out>, length=7, parser_state=0x7f3a1978a630, is_com_multi=<optimized out>, is_next_command=<optimized out>) at /data/src/10.3/sql/sql_parse.cc:8091
#33 0x000055e3b8bacf7e in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x7f3a080009a8, packet=packet@entry=0x7f3a08009319 "call sp", packet_length=packet_length@entry=7, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /data/src/10.3/sql/sql_parse.cc:1850
#34 0x000055e3b8bad620 in do_command (thd=0x7f3a080009a8) at /data/src/10.3/sql/sql_parse.cc:1395
#35 0x000055e3b8c7ee94 in do_handle_one_connection (connect=connect@entry=0x55e3bb1d4b88) at /data/src/10.3/sql/sql_connect.cc:1402
#36 0x000055e3b8c7f034 in handle_one_connection (arg=arg@entry=0x55e3bb1d4b88) at /data/src/10.3/sql/sql_connect.cc:1308
#37 0x000055e3b8f62714 in pfs_spawn_thread (arg=0x55e3bb245be8) at /data/src/10.3/storage/perfschema/pfs.cc:1862
#38 0x00007f3a210a1494 in start_thread (arg=0x7f3a1978b700) at pthread_create.c:333
#39 0x00007f3a1f6a293f in clone () from /lib/x86_64-linux-gnu/libc.so.6

Comment by Alice Sherepa [ 2022-06-28 ]

not reproducuble on the recent 10.3-10.10 (10.3 f339ef3f9793d5de8f825f1ec)

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