[MDEV-32956] Assertion `thd->active_stmt_arena_to_use()-> is_stmt_prepare_or_first_sp_execute() || thd->active_stmt_arena_to_use()-> is_conventional() || thd->active_stmt_arena_to_use()->state == Query_arena::STMT_SP_QUERY_ARGUMENTS' failed. Created: 2023-12-06  Updated: 2023-12-11  Resolved: 2023-12-11

Status: Closed
Project: MariaDB Server
Component/s: Prepared Statements
Affects Version/s: 10.4
Fix Version/s: 10.4.33, 10.5.24, 10.6.17, 10.11.7, 11.0.5, 11.1.4, 11.2.3, 11.3.2, 11.4.1

Type: Bug Priority: Major
Reporter: Ramesh Sivaraman Assignee: Dmitry Shulga
Resolution: Duplicate Votes: 0
Labels: debug


 Description   

CREATE TABLE t (a INT);
PREPARE s FROM 'SELECT GROUP_CONCAT(ta.a) FROM t AS ta,t AS tb';
SET NAMES utf8;
EXECUTE s;

Leads to:

10.4.33 5f89045221717533994da01fc270d4851ccdc06c (Debug)

mariadbd: /test/10.4_dbg/sql/item_sum.cc:4101: virtual bool Item_func_group_concat::fix_fields(THD*, Item**): Assertion `thd->active_stmt_arena_to_use()-> is_stmt_prepare_or_first_sp_execute() || thd->active_stmt_arena_to_use()-> is_conventional() || thd->active_stmt_arena_to_use()->state == Query_arena::STMT_SP_QUERY_ARGUMENTS' failed.

10.4.33 5f89045221717533994da01fc270d4851ccdc06c (Debug)

Core was generated by `/test/MD011223-mariadb-10.4.33-linux-x86_64-dbg/bin/mariadbd --no-defaults --co'.
Program terminated with signal SIGABRT, Aborted.
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
[Current thread is 1 (Thread 0x14b9e0062700 (LWP 1481859))]
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x000014b9e1a7e859 in __GI_abort () at abort.c:79
#2  0x000014b9e1a7e729 in __assert_fail_base (fmt=0x14b9e1c14588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x55e7924113a8 "thd->active_stmt_arena_to_use()-> is_stmt_prepare_or_first_sp_execute() || thd->active_stmt_arena_to_use()-> is_conventional() || thd->active_stmt_arena_to_use()->state == Query_arena::STMT_SP_QUERY_A"..., file=0x55e7924109c0 "/test/10.4_dbg/sql/item_sum.cc", line=4101, function=<optimized out>) at assert.c:92
#3  0x000014b9e1a8ffd6 in __GI___assert_fail (assertion=assertion@entry=0x55e7924113a8 "thd->active_stmt_arena_to_use()-> is_stmt_prepare_or_first_sp_execute() || thd->active_stmt_arena_to_use()-> is_conventional() || thd->active_stmt_arena_to_use()->state == Query_arena::STMT_SP_QUERY_A"..., file=file@entry=0x55e7924109c0 "/test/10.4_dbg/sql/item_sum.cc", line=line@entry=4101, function=function@entry=0x55e792411368 "virtual bool Item_func_group_concat::fix_fields(THD*, Item**)") at assert.c:101
#4  0x000055e7919bce99 in Item_func_group_concat::fix_fields (this=0x14b97c027280, thd=0x14b97c000d28, ref=0x14b97c027700) at /test/10.4_dbg/sql/sql_class.h:2800
#5  0x000055e79158f1db in Item::fix_fields_if_needed (ref=0x14b97c027700, thd=0x14b97c000d28, this=0x14b97c027280) at /test/10.4_dbg/sql/item.h:971
#6  Item::fix_fields_if_needed_for_scalar (ref=0x14b97c027700, thd=0x14b97c000d28, this=0x14b97c027280) at /test/10.4_dbg/sql/item.h:971
#7  setup_fields (thd=0x14b97c000d28, ref_pointer_array=<optimized out>, fields=<optimized out>, column_usage=column_usage@entry=MARK_COLUMNS_READ, sum_func_list=sum_func_list@entry=0x14b97c012b38, pre_fix=0x14b97c026dc0, allow_sum_func=true) at /test/10.4_dbg/sql/sql_base.cc:7747
#8  0x000055e791669eb1 in JOIN::prepare (this=this@entry=0x14b97c012818, tables_init=tables_init@entry=0x14b97c027788, wild_num=wild_num@entry=0, conds_init=conds_init@entry=0x0, og_num=og_num@entry=0, order_init=order_init@entry=0x0, skip_order_by=false, group_init=0x0, having_init=0x0, proc_param_init=0x0, select_lex_arg=0x14b97c026c48, unit_arg=0x14b97c025098) at /test/10.4_dbg/sql/sql_select.cc:1350
#9  0x000055e791682284 in mysql_select (thd=thd@entry=0x14b97c000d28, tables=0x14b97c027788, wild_num=0, fields=@0x14b97c026da8: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x14b97c0276f8, last = 0x14b97c0276f8, elements = 1}, <No data fields>}, conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=<optimized out>, result=0x14b97c028e30, unit=0x14b97c025098, select_lex=0x14b97c026c48) at /test/10.4_dbg/sql/sql_select.cc:4809
#10 0x000055e791682665 in handle_select (thd=thd@entry=0x14b97c000d28, lex=lex@entry=0x14b97c024fd8, result=result@entry=0x14b97c028e30, setup_tables_done_option=setup_tables_done_option@entry=0) at /test/10.4_dbg/sql/sql_select.cc:442
#11 0x000055e7915f7062 in execute_sqlcom_select (thd=thd@entry=0x14b97c000d28, all_tables=0x14b97c027788) at /test/10.4_dbg/sql/sql_parse.cc:6523
#12 0x000055e79160137c in mysql_execute_command (thd=0x14b97c000d28) at /test/10.4_dbg/sql/sql_parse.cc:3980
#13 0x000055e791623c05 in Prepared_statement::execute (this=this@entry=0x14b97c01e7d8, expanded_query=expanded_query@entry=0x14b9e005f990, open_cursor=open_cursor@entry=false) at /test/10.4_dbg/sql/sql_prepare.cc:5025
#14 0x000055e791623f79 in Prepared_statement::execute_loop (this=this@entry=0x14b97c01e7d8, expanded_query=expanded_query@entry=0x14b9e005f990, open_cursor=open_cursor@entry=false, packet=packet@entry=0x0, packet_end=packet_end@entry=0x0) at /test/10.4_dbg/sql/sql_prepare.cc:4472
#15 0x000055e7916245cd in mysql_sql_stmt_execute (thd=thd@entry=0x14b97c000d28) at /test/10.4_dbg/sql/sql_prepare.cc:3531
#16 0x000055e7916013dc in mysql_execute_command (thd=thd@entry=0x14b97c000d28) at /test/10.4_dbg/sql/sql_parse.cc:3996
#17 0x000055e79160bd6c in mysql_parse (thd=thd@entry=0x14b97c000d28, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x14b9e0061360, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/10.4_dbg/sql/sql_parse.cc:8062
#18 0x000055e79160ed7e in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x14b97c000d28, packet=packet@entry=0x14b97c019699 "EXECUTE s", packet_length=packet_length@entry=9, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/10.4_dbg/sql/sql_class.h:1242
#19 0x000055e7916119fd in do_command (thd=0x14b97c000d28) at /test/10.4_dbg/sql/sql_parse.cc:1378
#20 0x000055e79173d252 in do_handle_one_connection (connect=connect@entry=0x55e795999908) at /test/10.4_dbg/sql/sql_connect.cc:1419
#21 0x000055e79173d371 in handle_one_connection (arg=0x55e795999908) at /test/10.4_dbg/sql/sql_connect.cc:1323
#22 0x000014b9e1f8f609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#23 0x000014b9e1b7b133 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Bug confirmed present in:
MariaDB: 10.4.33 (dbg)

Bug (or feature/syntax) confirmed not present in:
MariaDB: 10.4.33 (opt), 10.5.24 (dbg), 10.5.24 (opt), 10.6.17 (dbg), 10.6.17 (opt), 10.11.7 (dbg), 10.11.7 (opt), 11.0.5 (dbg), 11.0.5 (opt), 11.1.4 (dbg), 11.1.4 (opt), 11.2.3 (dbg), 11.2.3 (opt), 11.3.2 (dbg), 11.3.2 (opt), 11.4.0 (dbg), 11.4.0 (opt)



 Comments   
Comment by Dmitry Shulga [ 2023-12-11 ]

Fixed by a commit for the task MDEV-32965

Generated at Thu Feb 08 10:35:18 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.