[MDEV-32965] 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-07  Updated: 2024-01-12  Resolved: 2023-12-11

Status: Closed
Project: MariaDB Server
Component/s: Prepared Statements
Affects Version/s: 10.4, 10.5
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: Blocker
Reporter: Elena Stepanova Assignee: Dmitry Shulga
Resolution: Fixed Votes: 0
Labels: regression

Issue Links:
Relates
relates to MDEV-33218 Assertion `active_arena->is_stmt_prep... In Progress

 Description   

Set to blocker as it's a recent regression. Otherwise the test case doesn't look meaningful.

CREATE TABLE t (f VARCHAR(8)) CHARACTER SET utf8;
INSERT INTO t VALUES ('foo'),('bar');
 
EXECUTE IMMEDIATE 'SELECT GROUP_CONCAT(@x) FROM t GROUP BY @x := f';
 
# Cleanup
DROP TABLE t;

10.4 ba94778d2c438d4c0f93ce031e504f7d78e895e1

mysqld: /data/bld/10.4-asan/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.
231207 14:59:30 [ERROR] mysqld got signal 6 ;
 
#9  0x00007f3cd9453e32 in __GI___assert_fail (assertion=0x5596f7d9b7e0 "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=0x5596f7d97760 "/data/bld/10.4-asan/sql/item_sum.cc", line=4101, function=0x5596f7d9b780 "virtual bool Item_func_group_concat::fix_fields(THD*, Item**)") at ./assert/assert.c:101
#10 0x00005596f63694ab in Item_func_group_concat::fix_fields (this=0x62b00008e500, thd=0x62b00005b208, ref=0x62b00008e990) at /data/bld/10.4-asan/sql/item_sum.cc:4101
#11 0x00005596f5691daf in Item::fix_fields_if_needed (this=0x62b00008e500, thd=0x62b00005b208, ref=0x62b00008e990) at /data/bld/10.4-asan/sql/item.h:967
#12 0x00005596f5691de5 in Item::fix_fields_if_needed_for_scalar (this=0x62b00008e500, thd=0x62b00005b208, ref=0x62b00008e990) at /data/bld/10.4-asan/sql/item.h:971
#13 0x00005596f57b840b in setup_fields (thd=0x62b00005b208, ref_pointer_array=..., fields=..., column_usage=MARK_COLUMNS_READ, sum_func_list=0x62b000062ee8, pre_fix=0x62b00008e030, allow_sum_func=true) at /data/bld/10.4-asan/sql/sql_base.cc:7747
#14 0x00005596f59e0511 in JOIN::prepare (this=0x62b000062bc8, tables_init=0x62b00008ea30, wild_num=0, conds_init=0x0, og_num=1, order_init=0x0, skip_order_by=false, group_init=0x62b00008f410, having_init=0x0, proc_param_init=0x0, select_lex_arg=0x62b00008deb8, unit_arg=0x62b00008c2e8) at /data/bld/10.4-asan/sql/sql_select.cc:1350
#15 0x00005596f5a05f66 in mysql_select (thd=0x62b00005b208, tables=0x62b00008ea30, wild_num=0, fields=..., conds=0x0, og_num=1, order=0x0, group=0x62b00008f410, having=0x0, proc_param=0x0, select_options=2416184064, result=0x62b00008fcd8, unit=0x62b00008c2e8, select_lex=0x62b00008deb8) at /data/bld/10.4-asan/sql/sql_select.cc:4809
#16 0x00005596f59d6cad in handle_select (thd=0x62b00005b208, lex=0x62b00008c228, result=0x62b00008fcd8, setup_tables_done_option=0) at /data/bld/10.4-asan/sql/sql_select.cc:442
#17 0x00005596f59415a0 in execute_sqlcom_select (thd=0x62b00005b208, all_tables=0x62b00008ea30) at /data/bld/10.4-asan/sql/sql_parse.cc:6523
#18 0x00005596f592e966 in mysql_execute_command (thd=0x62b00005b208) at /data/bld/10.4-asan/sql/sql_parse.cc:3980
#19 0x00005596f599e925 in Prepared_statement::execute (this=0x619000086688, expanded_query=0x7f3cd045fc90, open_cursor=false) at /data/bld/10.4-asan/sql/sql_prepare.cc:5025
#20 0x00005596f5999f93 in Prepared_statement::execute_loop (this=0x619000086688, expanded_query=0x7f3cd045fc90, open_cursor=false, packet=0x0, packet_end=0x0) at /data/bld/10.4-asan/sql/sql_prepare.cc:4472
#21 0x00005596f599fa38 in Prepared_statement::execute_immediate (this=0x619000086688, query=0x62b000062320 "SELECT GROUP_CONCAT(@x) FROM t GROUP BY @x := f", query_len=47) at /data/bld/10.4-asan/sql/sql_prepare.cc:5149
#22 0x00005596f5990cff in mysql_sql_stmt_execute_immediate (thd=0x62b00005b208) at /data/bld/10.4-asan/sql/sql_prepare.cc:2966
#23 0x00005596f592e983 in mysql_execute_command (thd=0x62b00005b208) at /data/bld/10.4-asan/sql/sql_parse.cc:3986
#24 0x00005596f594a88f in mysql_parse (thd=0x62b00005b208, rawbuf=0x62b000062228 "EXECUTE IMMEDIATE 'SELECT GROUP_CONCAT(@x) FROM t GROUP BY @x := f'", length=67, parser_state=0x7f3cd0461c60, is_com_multi=false, is_next_command=false) at /data/bld/10.4-asan/sql/sql_parse.cc:8062
#25 0x00005596f59208ea in dispatch_command (command=COM_QUERY, thd=0x62b00005b208, packet=0x62900021c209 "EXECUTE IMMEDIATE 'SELECT GROUP_CONCAT(@x) FROM t GROUP BY @x := f'", packet_length=67, is_com_multi=false, is_next_command=false) at /data/bld/10.4-asan/sql/sql_parse.cc:1857
#26 0x00005596f591d459 in do_command (thd=0x62b00005b208) at /data/bld/10.4-asan/sql/sql_parse.cc:1378
#27 0x00005596f5d24023 in do_handle_one_connection (connect=0x6080000009a8) at /data/bld/10.4-asan/sql/sql_connect.cc:1419
#28 0x00005596f5d2393a in handle_one_connection (arg=0x6080000009a8) at /data/bld/10.4-asan/sql/sql_connect.cc:1323
#29 0x00005596f69889fe in pfs_spawn_thread (arg=0x615000003508) at /data/bld/10.4-asan/storage/perfschema/pfs.cc:1869
#30 0x00007f3cd94a8044 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
#31 0x00007f3cd952861c in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81

Reproducible with at least MyISAM, InnoDB, Aria.

The failure started happening after this commit in 10.4:

commit 85f2e4f8e8c82978bd9cc0af9bfd2b549ea04d65
Author: Dmitry Shulga <dmitry.shulga@mariadb.com>
Date:   Fri Nov 24 16:28:31 2023 +0700
 
    MDEV-32466: Potential memory leak on executing of create view statement



 Comments   
Comment by Elena Stepanova [ 2023-12-10 ]

Other assertion failures apparently with the same root cause

mysqld: /home/vsts/src/sql/sp.cc:2737: void sp_update_stmt_used_routines(THD*, Query_tables_list*, HASH*, TABLE_LIST*): Assertion `thd->active_stmt_arena_to_use()-> is_stmt_prepare_or_first_stmt_execute() || thd->active_stmt_arena_to_use()-> is_conventional() || thd->active_stmt_arena_to_use()->state == Query_arena::STMT_SP_QUERY_ARGUMENTS' failed.

mysqld: /home/vsts/src/sql/sql_lex.cc:4761: void st_select_lex::fix_prepare_information(THD*, Item**, Item**): Assertion `active_arena->is_stmt_prepare_or_first_stmt_execute() || active_arena->state == Query_arena::STMT_SP_QUERY_ARGUMENTS' failed.

Comment by Oleksandr Byelkin [ 2023-12-11 ]

OK to push

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