[MDEV-27768] MDEV-25440: Assertion `(cs->state & 0x20000) == 0' failed in my_strnncollsp_nchars_generic_8bit Created: 2022-02-08  Updated: 2022-11-22  Resolved: 2022-11-22

Status: Closed
Project: MariaDB Server
Component/s: Character Sets
Affects Version/s: 10.4, 10.5, 10.6, 10.7, 10.8, 10.9, 10.10, 10.11
Fix Version/s: N/A

Type: Bug Priority: Critical
Reporter: Roel Van de Paar Assignee: Alexander Barkov
Resolution: Duplicate Votes: 0
Labels: affects-tests, regression

Issue Links:
Duplicate
duplicates MDEV-27670 Assertion `(cs->state & 0x20000) == 0... Closed
Problem/Incident
is caused by MDEV-25440 Assertion `cmp_rec_rec(rec, old_rec, ... Closed
Relates
relates to MDEV-25904 New collation functions to compare In... Closed
relates to MDEV-30034 UNIQUE USING HASH accepts duplicate e... Closed
relates to MDEV-30048 Prefix keys for CHAR work differently... Closed
relates to MDEV-30050 Inconsistent results of DISTINCT with... Closed

 Description   

Appears only in the MDEV-25440 branch, and only in debug. Likely other versions affected.

CREATE TABLE t (a INT KEY,b INT,c CHAR,KEY(b),KEY(c)) ROW_FORMAT=REDUNDANT COLLATE=tis620_thai_nopad_ci ENGINE=InnoDB;
INSERT INTO t VALUES (3,4,4);

Leads to:

10.5.14 cf63eecef44f189ce2d221612dee9dfc1885ba4e (Debug)

mysqld: /test/MDEV-25440-2-bb-10.5-release_dbg/strings/ctype.c:1380: my_strnncollsp_nchars_generic_8bit: Assertion `(cs->state & 0x20000) == 0' failed.

10.5.14 cf63eecef44f189ce2d221612dee9dfc1885ba4e (Debug)

Core was generated by `/test/MDEV-25440-2-MD040222-mariadb-10.5.14-linux-x86_64-dbg/bin/mysqld --no-de'.
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 0x1534e55cc700 (LWP 3277868))]
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00001534fc47b859 in __GI_abort () at abort.c:79
#2  0x00001534fc47b729 in __assert_fail_base (fmt=0x1534fc611588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x55f5f488374f "(cs->state & 0x20000) == 0", file=0x55f5f4883998 "/test/MDEV-25440-2-bb-10.5-release_dbg/strings/ctype.c", line=1380, function=<optimized out>) at assert.c:92
#3  0x00001534fc48cf36 in __GI___assert_fail (assertion=assertion@entry=0x55f5f488374f "(cs->state & 0x20000) == 0", file=file@entry=0x55f5f4883998 "/test/MDEV-25440-2-bb-10.5-release_dbg/strings/ctype.c", line=line@entry=1380, function=function@entry=0x55f5f48848c0 <__PRETTY_FUNCTION__.13851> "my_strnncollsp_nchars_generic_8bit") at assert.c:101
#4  0x000055f5f41be4b5 in my_strnncollsp_nchars_generic_8bit (cs=<optimized out>, str1=<optimized out>, len1=<optimized out>, str2=<optimized out>, len2=<optimized out>, nchars=<optimized out>) at /test/MDEV-25440-2-bb-10.5-release_dbg/strings/ctype.c:1380
#5  0x000055f5f3de62d4 in cmp_data (mtype=<optimized out>, prtype=<optimized out>, data1=data1@entry=0x15345c025821 "4", '\245' <repeats 22 times>, "\320X\002\\4\025", len1=len1@entry=1, data2=data2@entry=0x1534d87a4085 "4\200", len2=len2@entry=1) at /test/MDEV-25440-2-bb-10.5-release_dbg/storage/innobase/rem/rem0cmp.cc:293
#6  0x000055f5f3de6ef4 in cmp_dtuple_rec_with_match_low (dtuple=dtuple@entry=0x15345c021e70, rec=rec@entry=0x1534d87a4085 "4\200", offsets=offsets@entry=0x1534e55c94f0, n_cmp=2, matched_fields=matched_fields@entry=0x1534e55c8d88) at /test/MDEV-25440-2-bb-10.5-release_dbg/storage/innobase/rem/rem0cmp.cc:411
#7  0x000055f5f3de728e in cmp_dtuple_rec (dtuple=dtuple@entry=0x15345c021e70, rec=rec@entry=0x1534d87a4085 "4\200", offsets=0x1534e55c94f0) at /test/MDEV-25440-2-bb-10.5-release_dbg/storage/innobase/include/data0data.inl:253
#8  0x000055f5f3f64556 in page_cur_tuple_insert (cursor=cursor@entry=0x1534e55c9368, tuple=tuple@entry=0x15345c021e70, index=index@entry=0x15345c0238b8, offsets=offsets@entry=0x1534e55c92b8, heap=heap@entry=0x1534e55c92a8, n_ext=<optimized out>, mtr=0x1534e55c98d0) at /test/MDEV-25440-2-bb-10.5-release_dbg/storage/innobase/include/page0cur.inl:289
#9  0x000055f5f3f685da in btr_cur_optimistic_insert (flags=flags@entry=0, cursor=cursor@entry=0x1534e55c9360, offsets=offsets@entry=0x1534e55c92b8, heap=heap@entry=0x1534e55c92a8, entry=entry@entry=0x15345c021e70, rec=rec@entry=0x1534e55c9310, big_rec=0x1534e55c9400, n_ext=<optimized out>, thr=0x15345c028640, mtr=0x1534e55c98d0) at /test/MDEV-25440-2-bb-10.5-release_dbg/storage/innobase/btr/btr0cur.cc:3564
#10 0x000055f5f3e2493b in row_ins_sec_index_entry_low (flags=flags@entry=0, mode=mode@entry=2, index=index@entry=0x15345c0238b8, offsets_heap=<optimized out>, offsets_heap@entry=0x15345c06c928, heap=heap@entry=0x15345c06cdc8, entry=entry@entry=0x15345c021e70, trx_id=0, thr=0x15345c028640) at /test/MDEV-25440-2-bb-10.5-release_dbg/storage/innobase/row/row0ins.cc:3093
#11 0x000055f5f3e2acb8 in row_ins_sec_index_entry (index=index@entry=0x15345c0238b8, entry=entry@entry=0x15345c021e70, thr=thr@entry=0x15345c028640, check_foreign=check_foreign@entry=true) at /test/MDEV-25440-2-bb-10.5-release_dbg/storage/innobase/row/row0ins.cc:3294
#12 0x000055f5f3e2c9bb in row_ins_index_entry (thr=0x15345c028640, entry=0x15345c021e70, index=0x15345c0238b8) at /test/MDEV-25440-2-bb-10.5-release_dbg/storage/innobase/row/row0ins.cc:3342
#13 row_ins_index_entry_step (thr=0x15345c028640, node=0x15345c0283e0) at /test/MDEV-25440-2-bb-10.5-release_dbg/storage/innobase/row/row0ins.cc:3508
#14 row_ins (thr=0x15345c028640, node=0x15345c0283e0) at /test/MDEV-25440-2-bb-10.5-release_dbg/storage/innobase/row/row0ins.cc:3667
#15 row_ins_step (thr=thr@entry=0x15345c028640) at /test/MDEV-25440-2-bb-10.5-release_dbg/storage/innobase/row/row0ins.cc:3817
#16 0x000055f5f3e516aa in row_insert_for_mysql (mysql_rec=mysql_rec@entry=0x15345c025818 "\371\003", prebuilt=0x15345c027e88, ins_mode=ROW_INS_NORMAL) at /test/MDEV-25440-2-bb-10.5-release_dbg/storage/innobase/row/row0mysql.cc:1400
#17 0x000055f5f3cbd954 in ha_innobase::write_row (this=0x15345c01e660, record=0x15345c025818 "\371\003") at /test/MDEV-25440-2-bb-10.5-release_dbg/storage/innobase/handler/ha_innodb.cc:7708
#18 0x000055f5f38cdff6 in handler::ha_write_row (this=0x15345c01e660, buf=0x15345c025818 "\371\003") at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/handler.cc:7174
#19 0x000055f5f359cb94 in write_record (thd=thd@entry=0x15345c000db8, table=table@entry=0x15345c026d08, info=info@entry=0x1534e55cac70, sink=sink@entry=0x0) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_insert.cc:2140
#20 0x000055f5f35a922b in mysql_insert (thd=thd@entry=0x15345c000db8, table_list=0x15345c013dd0, fields=@0x15345c005e38: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x55f5f4c64300 <end_of_list>, last = 0x15345c005e38, elements = 0}, <No data fields>}, values_list=@0x15345c005e80: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x15345c014b60, last = 0x15345c014b60, elements = 1}, <No data fields>}, update_fields=@0x15345c005e68: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x55f5f4c64300 <end_of_list>, last = 0x15345c005e68, elements = 0}, <No data fields>}, update_values=@0x15345c005e50: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x55f5f4c64300 <end_of_list>, last = 0x15345c005e50, elements = 0}, <No data fields>}, duplic=DUP_ERROR, ignore=false, result=0x0) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_insert.cc:1118
#21 0x000055f5f35f15ed in mysql_execute_command (thd=thd@entry=0x15345c000db8) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_parse.cc:4624
#22 0x000055f5f35daf34 in mysql_parse (thd=thd@entry=0x15345c000db8, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x1534e55cb3d0, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_parse.cc:8100
#23 0x000055f5f35ea787 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x15345c000db8, packet=packet@entry=0x15345c00b4a9 "INSERT INTO t VALUES (3,4,4)", packet_length=packet_length@entry=28, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_class.h:1290
#24 0x000055f5f35ee003 in do_command (thd=0x15345c000db8) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_parse.cc:1370
#25 0x000055f5f374ad24 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x55f5f7126ad8, put_in_cache=put_in_cache@entry=true) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_connect.cc:1418
#26 0x000055f5f374b427 in handle_one_connection (arg=arg@entry=0x55f5f7126ad8) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_connect.cc:1312
#27 0x000055f5f3c04845 in pfs_spawn_thread (arg=0x55f5f7064588) at /test/MDEV-25440-2-bb-10.5-release_dbg/storage/perfschema/pfs.cc:2201
#28 0x00001534fc98a609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#29 0x00001534fc578293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95



 Comments   
Comment by Roel Van de Paar [ 2022-02-08 ]

CREATE TABLE t (C1 CHAR KEY,B1 BIT,B2 BIT,C2 CHAR DEFAULT'') ROW_FORMAT=DYNAMIC COLLATE=tis620_thai_nopad_ci ENGINE=InnoDB;
SELECT HEX(c1),HEX (c2) FROM t WHERE c1>=''AND c1<''AND c2=''LIMIT 2;

Leads to same assert, different stack:

10.5.14 cf63eecef44f189ce2d221612dee9dfc1885ba4e (Debug)

mysqld: /test/MDEV-25440-2-bb-10.5-release_dbg/strings/ctype.c:1380: my_strnncollsp_nchars_generic_8bit: Assertion `(cs->state & 0x20000) == 0' failed.

10.5.14 cf63eecef44f189ce2d221612dee9dfc1885ba4e (Debug)

Core was generated by `/test/MDEV-25440-2-MD040222-mariadb-10.5.14-linux-x86_64-dbg/bin/mysqld --no-de'.
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 0x14f5600b3700 (LWP 2641661))]
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x000014f563e93859 in __GI_abort () at abort.c:79
#2  0x000014f563e93729 in __assert_fail_base (fmt=0x14f564029588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x55918e3bd74f "(cs->state & 0x20000) == 0", file=0x55918e3bd998 "/test/MDEV-25440-2-bb-10.5-release_dbg/strings/ctype.c", line=1380, function=<optimized out>) at assert.c:92
#3  0x000014f563ea4f36 in __GI___assert_fail (assertion=assertion@entry=0x55918e3bd74f "(cs->state & 0x20000) == 0", file=file@entry=0x55918e3bd998 "/test/MDEV-25440-2-bb-10.5-release_dbg/strings/ctype.c", line=line@entry=1380, function=function@entry=0x55918e3be8c0 <__PRETTY_FUNCTION__.13851> "my_strnncollsp_nchars_generic_8bit") at assert.c:101
#4  0x000055918dcf84b5 in my_strnncollsp_nchars_generic_8bit (cs=<optimized out>, str1=<optimized out>, len1=<optimized out>, str2=<optimized out>, len2=<optimized out>, nchars=<optimized out>) at /test/MDEV-25440-2-bb-10.5-release_dbg/strings/ctype.c:1380
#5  0x000055918d3bbf6c in Field_string::cmp (this=<optimized out>, a_ptr=<optimized out>, b_ptr=<optimized out>) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/field.h:2087
#6  0x000055918d26a555 in Field::key_cmp (this=<optimized out>, a=<optimized out>, b=<optimized out>) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/field.h:1296
#7  0x000055918d5b0305 in SEL_ARG::sel_cmp (field=<optimized out>, a=<optimized out>, b=<optimized out>, a_flag=<optimized out>, b_flag=<optimized out>) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/opt_range.cc:2150
#8  0x000055918d5bcb66 in SEL_ARG::cmp_max_to_min (arg=<optimized out>, this=<optimized out>) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/opt_range.h:390
#9  get_range (e1=e1@entry=0x14f5600b09c8, e2=e2@entry=0x14f5600b09c0, root1=root1@entry=0x14f4f806b8c8) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/opt_range.cc:10036
#10 0x000055918d5c0875 in key_and (param=param@entry=0x14f5600b0c80, key1=key1@entry=0x14f4f806b7d0, key2=key2@entry=0x14f4f806b8c8, clone_flag=clone_flag@entry=0) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/opt_range.cc:9996
#11 0x000055918d5c0f74 in key_and_with_limit (clone_flag=0, key2=<optimized out>, key1=0x14f4f806b7d0, keyno=0, param=0x14f5600b0c80) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/opt_range.cc:10143
#12 and_range_trees (param=param@entry=0x14f5600b0c80, tree1=tree1@entry=0x14f4f806b748, tree2=tree2@entry=0x14f4f806b840, result=result@entry=0x14f4f806b748) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/opt_range.cc:9207
#13 0x000055918d5c1661 in tree_and (param=param@entry=0x14f5600b0c80, tree1=tree1@entry=0x14f4f806b748, tree2=0x14f4f806b840) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/opt_range.cc:9319
#14 0x000055918d5c4368 in Item_cond_and::get_mm_tree (this=<optimized out>, param=0x14f5600b0c80, cond_ptr=<optimized out>) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/opt_range.cc:8339
#15 0x000055918d5c3e56 in SQL_SELECT::test_quick_select (this=this@entry=0x14f4f80187b0, thd=thd@entry=0x14f4f8000db8, keys_to_use=<optimized out>, prev_tables=prev_tables@entry=0, limit=limit@entry=2, force_quick_range=force_quick_range@entry=false, ordered_output=false, remove_false_parts_of_where=true, only_single_index_range_scan=false) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/opt_range.cc:2883
#16 0x000055918d1a275a in get_quick_record_count (limit=2, keys=0x14f4f80175e0, table=0x14f4f8022148, select=0x14f4f80187b0, thd=0x14f4f8000db8) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_select.cc:4825
#17 make_join_statistics (join=join@entry=0x14f4f8016680, tables_list=@0x14f4f8014018: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x14f4f8016bf8, last = 0x14f4f8016bf8, elements = 1}, <No data fields>}, keyuse_array=keyuse_array@entry=0x14f4f8016970) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_select.cc:5552
#18 0x000055918d1a9dec in JOIN::optimize_inner (this=this@entry=0x14f4f8016680) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_select.cc:2296
#19 0x000055918d1aa196 in JOIN::optimize (this=this@entry=0x14f4f8016680) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_select.cc:1668
#20 0x000055918d1aab10 in mysql_select (thd=thd@entry=0x14f4f8000db8, tables=0x14f4f8014800, fields=@0x14f4f8013f28: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x14f4f80144e8, last = 0x14f4f8014798, elements = 2}, <No data fields>}, conds=0x14f4f8015730, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x14f4f8016658, unit=0x14f4f8004f60, select_lex=0x14f4f8013dd8) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_select.cc:4767
#21 0x000055918d1aae25 in handle_select (thd=thd@entry=0x14f4f8000db8, lex=lex@entry=0x14f4f8004e98, result=result@entry=0x14f4f8016658, setup_tables_done_option=setup_tables_done_option@entry=0) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_select.cc:444
#22 0x000055918d11c455 in execute_sqlcom_select (thd=thd@entry=0x14f4f8000db8, all_tables=0x14f4f8014800) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_parse.cc:6314
#23 0x000055918d129bba in mysql_execute_command (thd=thd@entry=0x14f4f8000db8) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_parse.cc:4005
#24 0x000055918d114f34 in mysql_parse (thd=thd@entry=0x14f4f8000db8, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x14f5600b23d0, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_parse.cc:8100
#25 0x000055918d124787 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x14f4f8000db8, packet=packet@entry=0x14f4f800b4a9 "SELECT HEX(c1),HEX (c2) FROM t WHERE c1>=''AND c1<''AND c2=''LIMIT 2", packet_length=packet_length@entry=68, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_class.h:1290
#26 0x000055918d128003 in do_command (thd=0x14f4f8000db8) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_parse.cc:1370
#27 0x000055918d284d24 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x55919189c188, put_in_cache=put_in_cache@entry=true) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_connect.cc:1418
#28 0x000055918d285427 in handle_one_connection (arg=arg@entry=0x55919189c188) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_connect.cc:1312
#29 0x000055918d73e845 in pfs_spawn_thread (arg=0x5591917e5ed8) at /test/MDEV-25440-2-bb-10.5-release_dbg/storage/perfschema/pfs.cc:2201
#30 0x000014f5643a2609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#31 0x000014f563f90293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Comment by Roel Van de Paar [ 2022-02-08 ]

SET sql_mode='';
CREATE TABLE t (a INT UNSIGNED,b INT,c CHAR(1),d BINARY (1),e VARCHAR(1),f VARBINARY(1),g BLOB,h BLOB,id INT,KEY(b),KEY(e)) ROW_FORMAT=REDUNDANT COLLATE=tis620_thai_nopad_ci ENGINE=InnoDB;
INSERT INTO t VALUES (4386060749083099108,157,0,0,0,0,0,0,12);
INSERT INTO t VALUES (104,15158706241929488558,0,0,0,0,0,0,13);
SELECT GROUP_CONCAT(DISTINCT a,b ORDER BY c,b) FROM t;

Leads to same assert, different stack:

10.5.14 cf63eecef44f189ce2d221612dee9dfc1885ba4e (Debug)

mysqld: /test/MDEV-25440-2-bb-10.5-release_dbg/strings/ctype.c:1380: my_strnncollsp_nchars_generic_8bit: Assertion `(cs->state & 0x20000) == 0' failed.

10.5.14 cf63eecef44f189ce2d221612dee9dfc1885ba4e (Debug)

Core was generated by `/test/MDEV-25440-2-MD040222-mariadb-10.5.14-linux-x86_64-dbg/bin/mysqld --no-de'.
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 0x150414cb4700 (LWP 3394680))]
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x0000150417893859 in __GI_abort () at abort.c:79
#2  0x0000150417893729 in __assert_fail_base (fmt=0x150417a29588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x56416031274f "(cs->state & 0x20000) == 0", file=0x564160312998 "/test/MDEV-25440-2-bb-10.5-release_dbg/strings/ctype.c", line=1380, function=<optimized out>) at assert.c:92
#3  0x00001504178a4f36 in __GI___assert_fail (assertion=assertion@entry=0x56416031274f "(cs->state & 0x20000) == 0", file=file@entry=0x564160312998 "/test/MDEV-25440-2-bb-10.5-release_dbg/strings/ctype.c", line=line@entry=1380, function=function@entry=0x5641603138c0 <__PRETTY_FUNCTION__.13851> "my_strnncollsp_nchars_generic_8bit") at assert.c:101
#4  0x000056415fc4d4b5 in my_strnncollsp_nchars_generic_8bit (cs=<optimized out>, str1=<optimized out>, len1=<optimized out>, str2=<optimized out>, len2=<optimized out>, nchars=<optimized out>) at /test/MDEV-25440-2-bb-10.5-release_dbg/strings/ctype.c:1380
#5  0x000056415f310f6c in Field_string::cmp (this=<optimized out>, a_ptr=<optimized out>, b_ptr=<optimized out>) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/field.h:2087
#6  0x000056415f46c293 in group_concat_key_cmp_with_order (arg=<optimized out>, key1=0x150390185058, key2=0x150390073c91) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/item_sum.cc:3660
#7  0x000056415fbfff9e in tree_insert (tree=0x1503900149c0, key=0x150390073c91, key_size=key_size@entry=0, custom_arg=custom_arg@entry=0x150390014868) at /test/MDEV-25440-2-bb-10.5-release_dbg/mysys/tree.c:248
#8  0x000056415f479d0f in Item_func_group_concat::add (this=this@entry=0x150390014868, exclude_nulls=true) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/item_sum.cc:4191
#9  0x000056415f481da6 in Item_func_group_concat::add (this=0x150390014868) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/item_sum.h:1976
#10 0x000056415f47aaed in Aggregator_simple::add (this=<optimized out>) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/item_sum.h:718
#11 0x000056415f0ad409 in Item_sum::aggregator_add (this=<optimized out>) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/item_sum.h:560
#12 update_sum_func (func_ptr=0x150390016570) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_select.cc:26002
#13 0x000056415f0eca45 in end_send_group (join=0x150390015df8, join_tab=<optimized out>, end_of_records=<optimized out>) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_select.cc:22324
#14 0x000056415f0b2315 in evaluate_join_record (join=join@entry=0x150390015df8, join_tab=join_tab@entry=0x150390017188, error=error@entry=0) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_select.cc:21126
#15 0x000056415f0c8703 in sub_select (join=0x150390015df8, join_tab=0x150390017188, end_of_records=<optimized out>) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_select.cc:20935
#16 0x000056415f10148e in do_select (procedure=0x0, join=0x150390015df8) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_select.cc:20428
#17 JOIN::exec_inner (this=this@entry=0x150390015df8) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_select.cc:4524
#18 0x000056415f1019d8 in JOIN::exec (this=this@entry=0x150390015df8) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_select.cc:4304
#19 0x000056415f0ffb5f in mysql_select (thd=thd@entry=0x150390000db8, tables=0x150390014de8, fields=@0x150390013f08: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x150390014d28, last = 0x150390014d28, elements = 1}, <No data fields>}, conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x150390015dd0, unit=0x150390004f60, select_lex=0x150390013db8) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_select.cc:4781
#20 0x000056415f0ffe25 in handle_select (thd=thd@entry=0x150390000db8, lex=lex@entry=0x150390004e98, result=result@entry=0x150390015dd0, setup_tables_done_option=setup_tables_done_option@entry=0) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_select.cc:444
#21 0x000056415f071455 in execute_sqlcom_select (thd=thd@entry=0x150390000db8, all_tables=0x150390014de8) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_parse.cc:6314
#22 0x000056415f07ebba in mysql_execute_command (thd=thd@entry=0x150390000db8) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_parse.cc:4005
#23 0x000056415f069f34 in mysql_parse (thd=thd@entry=0x150390000db8, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x150414cb33d0, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_parse.cc:8100
#24 0x000056415f079787 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x150390000db8, packet=packet@entry=0x15039000b4a9 "", packet_length=packet_length@entry=53, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_class.h:1290
#25 0x000056415f07d003 in do_command (thd=0x150390000db8) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_parse.cc:1370
#26 0x000056415f1d9d24 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x5641622990b8, put_in_cache=put_in_cache@entry=true) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_connect.cc:1418
#27 0x000056415f1da427 in handle_one_connection (arg=arg@entry=0x5641622990b8) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_connect.cc:1312
#28 0x000056415f693845 in pfs_spawn_thread (arg=0x5641621e2e08) at /test/MDEV-25440-2-bb-10.5-release_dbg/storage/perfschema/pfs.cc:2201
#29 0x0000150417da2609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#30 0x0000150417990293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

In regular 10.5 this leads to:

10.5.14 059a8fd87eb900a5a12185b1963e5623df874c21 (Debug)

10.5.14-dbg>SELECT GROUP_CONCAT(DISTINCT a,b ORDER BY c,b) FROM t;
+-----------------------------------------+
| GROUP_CONCAT(DISTINCT a,b ORDER BY c,b) |
+-----------------------------------------+
| 4294967295157,1042147483647             |
+-----------------------------------------+
1 row in set (0.004 sec)

Comment by Roel Van de Paar [ 2022-02-09 ]

CREATE TABLE t (a CHAR) ROW_FORMAT=DYNAMIC COLLATE=tis620_thai_nopad_ci PARTITION BY RANGE COLUMNS (a) (PARTITION p0 VALUES LESS THAN (''),PARTITION p VALUES LESS THAN (''));

Leads to same assert, different stack:

10.5.14 cf63eecef44f189ce2d221612dee9dfc1885ba4e (Debug)

mysqld: /test/MDEV-25440-2-bb-10.5-release_dbg/strings/ctype.c:1380: my_strnncollsp_nchars_generic_8bit: Assertion `(cs->state & 0x20000) == 0' failed.

10.5.14 cf63eecef44f189ce2d221612dee9dfc1885ba4e (Debug)

Core was generated by `/test/MDEV-25440-2-MD040222-mariadb-10.5.14-linux-x86_64-dbg/bin/mysqld --no-de'.
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 0x1493685b0700 (LWP 770686))]
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x000014937f47c859 in __GI_abort () at abort.c:79
#2  0x000014937f47c729 in __assert_fail_base (fmt=0x14937f612588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x5652179c774f "(cs->state & 0x20000) == 0", file=0x5652179c7998 "/test/MDEV-25440-2-bb-10.5-release_dbg/strings/ctype.c", line=1380, function=<optimized out>) at assert.c:92
#3  0x000014937f48df36 in __GI___assert_fail (assertion=assertion@entry=0x5652179c774f "(cs->state & 0x20000) == 0", file=file@entry=0x5652179c7998 "/test/MDEV-25440-2-bb-10.5-release_dbg/strings/ctype.c", line=line@entry=1380, function=function@entry=0x5652179c88c0 <__PRETTY_FUNCTION__.13851> "my_strnncollsp_nchars_generic_8bit") at assert.c:101
#4  0x00005652173024b5 in my_strnncollsp_nchars_generic_8bit (cs=<optimized out>, str1=<optimized out>, len1=<optimized out>, str2=<optimized out>, len2=<optimized out>, nchars=<optimized out>) at /test/MDEV-25440-2-bb-10.5-release_dbg/strings/ctype.c:1380
#5  0x00005652169c5f6c in Field_string::cmp (this=<optimized out>, a_ptr=<optimized out>, b_ptr=<optimized out>) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/field.h:2087
#6  0x0000565216c039b7 in partition_info_compare_column_values (first_arg=first_arg@entry=0x1492e80150d8, second_arg=second_arg@entry=0x1492e80151e0) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_partition.cc:1250
#7  0x0000565216c06c02 in check_range_constants (thd=0x1492e8000db8, part_info=0x1492e8014dc0) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_partition.cc:1318
#8  0x0000565216c0adb5 in fix_partition_func (thd=thd@entry=0x1492e8000db8, table=table@entry=0x1493685ad350, is_create_table_ind=is_create_table_ind@entry=true) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_partition.cc:2023
#9  0x0000565216846381 in open_table_from_share (thd=thd@entry=0x1492e8000db8, share=share@entry=0x1493685ad920, alias=<optimized out>, db_stat=db_stat@entry=0, prgflag=prgflag@entry=1, ha_open_flags=ha_open_flags@entry=0, outparam=0x1493685ad350, is_create_table=true, partitions_to_open=0x0) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/table.cc:4167
#10 0x0000565216a0d528 in ha_create_table (thd=thd@entry=0x1492e8000db8, path=path@entry=0x1493685ae760 "./test/t", db=0x1492e80145e0 "test", table_name=0x1492e8013ed0 "t", create_info=create_info@entry=0x1493685aeb80, frm=frm@entry=0x1493685ae750) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/handler.cc:5570
#11 0x0000565216809f94 in create_table_impl (thd=thd@entry=0x1492e8000db8, orig_db=@0x1492e8013f20: {str = 0x1492e80145e0 "test", length = 4}, orig_table_name=@0x1492e8013f30: {str = 0x1492e8013ed0 "t", length = 1}, db=@0x1492e8013f20: {str = 0x1492e80145e0 "test", length = 4}, table_name=@0x1492e8013f30: {str = 0x1492e8013ed0 "t", length = 1}, path=path@entry=0x1493685ae760 "./test/t", options={m_options = DDL_options_st::OPT_NONE}, create_info=0x1493685aeb80, alter_info=0x1493685aeab0, create_table_mode=0, is_trans=0x1493685ae9d7, key_info=0x1493685ae748, key_count=0x1493685ae744, frm=0x1493685ae750) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_table.cc:5416
#12 0x000056521680a4f9 in mysql_create_table_no_lock (thd=thd@entry=0x1492e8000db8, db=db@entry=0x1492e8013f20, table_name=table_name@entry=0x1492e8013f30, create_info=create_info@entry=0x1493685aeb80, alter_info=alter_info@entry=0x1493685aeab0, is_trans=is_trans@entry=0x1493685ae9d7, create_table_mode=0, table_list=0x1492e8013f08) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_table.cc:5500
#13 0x000056521680a865 in mysql_create_table (thd=thd@entry=0x1492e8000db8, create_table=create_table@entry=0x1492e8013f08, create_info=create_info@entry=0x1493685aeb80, alter_info=alter_info@entry=0x1493685aeab0) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_table.cc:5604
#14 0x000056521680c2a4 in Sql_cmd_create_table_like::execute (this=<optimized out>, thd=0x1492e8000db8) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_table.cc:12276
#15 0x0000565216739537 in mysql_execute_command (thd=thd@entry=0x1492e8000db8) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_parse.cc:6056
#16 0x000056521671ef34 in mysql_parse (thd=thd@entry=0x1492e8000db8, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x1493685af3d0, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_parse.cc:8100
#17 0x000056521672e787 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x1492e8000db8, packet=packet@entry=0x1492e800b4a9 "CREATE TABLE t (a CHAR) ROW_FORMAT=DYNAMIC COLLATE=tis620_thai_nopad_ci PARTITION BY RANGE COLUMNS (a) (PARTITION p0 VALUES LESS THAN (''),PARTITION p VALUES LESS THAN (''))", packet_length=packet_length@entry=173, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_class.h:1290
#18 0x0000565216732003 in do_command (thd=0x1492e8000db8) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_parse.cc:1370
#19 0x000056521688ed24 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x5652195acd88, put_in_cache=put_in_cache@entry=true) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_connect.cc:1418
#20 0x000056521688f427 in handle_one_connection (arg=arg@entry=0x5652195acd88) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_connect.cc:1312
#21 0x0000565216d48845 in pfs_spawn_thread (arg=0x5652194e7828) at /test/MDEV-25440-2-bb-10.5-release_dbg/storage/perfschema/pfs.cc:2201
#22 0x000014937f98b609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#23 0x000014937f579293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Comment by Roel Van de Paar [ 2022-02-09 ]

CREATE TABLE t (a CHAR(9),b CHAR(7)) COLLATE=tis620_thai_nopad_ci;
INSERT INTO t VALUES (0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0);
ALTER TABLE t ADD INDEX kb (b),ADD INDEX kab (a,b),ALGORITHM=INPLACE;

Leads to same assert, different stack:

10.5.14 cf63eecef44f189ce2d221612dee9dfc1885ba4e (Debug)

mysqld: /test/MDEV-25440-2-bb-10.5-release_dbg/strings/ctype.c:1380: my_strnncollsp_nchars_generic_8bit: Assertion `(cs->state & 0x20000) == 0' failed.

10.5.14 cf63eecef44f189ce2d221612dee9dfc1885ba4e (Debug)

Core was generated by `/test/MDEV-25440-2-MD040222-mariadb-10.5.14-linux-x86_64-dbg/bin/mysqld --no-de'.
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 0x147c940fd700 (LWP 1794618))]
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x0000147c9d382859 in __GI_abort () at abort.c:79
#2  0x0000147c9d382729 in __assert_fail_base (fmt=0x147c9d518588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x5628299d274f "(cs->state & 0x20000) == 0", file=0x5628299d2998 "/test/MDEV-25440-2-bb-10.5-release_dbg/strings/ctype.c", line=1380, function=<optimized out>) at assert.c:92
#3  0x0000147c9d393f36 in __GI___assert_fail (assertion=assertion@entry=0x5628299d274f "(cs->state & 0x20000) == 0", file=file@entry=0x5628299d2998 "/test/MDEV-25440-2-bb-10.5-release_dbg/strings/ctype.c", line=line@entry=1380, function=function@entry=0x5628299d38c0 <__PRETTY_FUNCTION__.13851> "my_strnncollsp_nchars_generic_8bit") at assert.c:101
#4  0x000056282930d4b5 in my_strnncollsp_nchars_generic_8bit (cs=<optimized out>, str1=<optimized out>, len1=<optimized out>, str2=<optimized out>, len2=<optimized out>, nchars=<optimized out>) at /test/MDEV-25440-2-bb-10.5-release_dbg/strings/ctype.c:1380
#5  0x0000562828f352d4 in cmp_data (mtype=<optimized out>, prtype=<optimized out>, data1=0x147bf4076ee8 "0      ", len1=len1@entry=7, data2=data2@entry=0x147bf4076f28 "0      ", len2=len2@entry=7) at /test/MDEV-25440-2-bb-10.5-release_dbg/storage/innobase/rem/rem0cmp.cc:293
#6  0x0000562828f353dd in cmp_data_data (mtype=<optimized out>, prtype=<optimized out>, data1=<optimized out>, len1=len1@entry=7, data2=data2@entry=0x147bf4076f28 "0      ", len2=len2@entry=7) at /test/MDEV-25440-2-bb-10.5-release_dbg/storage/innobase/rem/rem0cmp.cc:332
#7  0x0000562828f83da9 in cmp_dfield_dfield (dfield2=0x147bf4076f10, dfield1=0x147bf4076eb8) at /test/MDEV-25440-2-bb-10.5-release_dbg/storage/innobase/include/data0data.h:599
#8  row_merge_tuple_cmp (n_uniq=n_uniq@entry=2, n_field=n_field@entry=2, a=@0x147bf40ba128: {fields = 0x147bf4076eb8}, b=@0x147bf40ba130: {fields = 0x147bf4076ef8}, dup=dup@entry=0x0) at /test/MDEV-25440-2-bb-10.5-release_dbg/storage/innobase/row/row0merge.cc:891
#9  0x0000562828f84064 in row_merge_tuple_sort (n_uniq=n_uniq@entry=2, n_field=n_field@entry=2, dup=dup@entry=0x0, tuples=tuples@entry=0x147bf40ba128, aux=aux@entry=0x147bf41579c0, low=low@entry=0, high=2) at /test/MDEV-25440-2-bb-10.5-release_dbg/storage/innobase/row/row0merge.cc:966
#10 0x0000562828f83ed0 in row_merge_tuple_sort (n_uniq=n_uniq@entry=2, n_field=n_field@entry=2, dup=dup@entry=0x0, tuples=tuples@entry=0x147bf40ba128, aux=aux@entry=0x147bf41579c0, low=low@entry=0, high=5) at /test/MDEV-25440-2-bb-10.5-release_dbg/storage/innobase/row/row0merge.cc:966
#11 0x0000562828f83ed0 in row_merge_tuple_sort (n_uniq=2, n_field=n_field@entry=2, dup=dup@entry=0x0, tuples=tuples@entry=0x147bf40ba128, aux=aux@entry=0x147bf41579c0, low=low@entry=0, high=10) at /test/MDEV-25440-2-bb-10.5-release_dbg/storage/innobase/row/row0merge.cc:966
#12 0x0000562828f841d2 in row_merge_buf_sort (buf=buf@entry=0x56282cf9be28, dup=dup@entry=0x0) at /test/MDEV-25440-2-bb-10.5-release_dbg/storage/innobase/include/dict0dict.inl:739
#13 0x0000562828f93960 in row_merge_read_clustered_index (allow_not_null=<optimized out>, eval_table=<optimized out>, crypt_block=<optimized out>, pct_cost=<optimized out>, stage=<optimized out>, tmpfd=0x147c940f8440, skip_pk_sort=<optimized out>, block=<optimized out>, sequence=<optimized out>, add_autoinc=<optimized out>, col_map=<optimized out>, add_v=<optimized out>, defaults=<optimized out>, n_index=<optimized out>, key_numbers=<optimized out>, files=<optimized out>, psort_info=<optimized out>, fts_sort_idx=<optimized out>, index=0x147bf4076b10, online=<optimized out>, new_table=<optimized out>, old_table=0x147bf401e928, table=<optimized out>, trx=<optimized out>) at /test/MDEV-25440-2-bb-10.5-release_dbg/storage/innobase/row/row0merge.cc:2553
#14 row_merge_build_indexes (trx=<optimized out>, old_table=0x147bf401e928, new_table=<optimized out>, online=<optimized out>, indexes=0x147bf4076b10, key_numbers=<optimized out>, n_indexes=<optimized out>, table=<optimized out>, defaults=<optimized out>, col_map=<optimized out>, add_autoinc=<optimized out>, sequence=<optimized out>, skip_pk_sort=<optimized out>, stage=<optimized out>, add_v=<optimized out>, eval_table=<optimized out>, allow_not_null=<optimized out>) at /test/MDEV-25440-2-bb-10.5-release_dbg/storage/innobase/row/row0merge.cc:4536
#15 0x0000562828e478ab in ha_innobase::inplace_alter_table (this=0x147bf4024af0, altered_table=0x147c940f9800, ha_alter_info=0x147c940f9760) at /test/MDEV-25440-2-bb-10.5-release_dbg/storage/innobase/handler/handler0alter.cc:8492
#16 0x0000562828807280 in handler::ha_inplace_alter_table (ha_alter_info=0x147c940f9760, altered_table=0x147c940f9800, this=<optimized out>) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/handler.h:4594
#17 mysql_inplace_alter_table (thd=thd@entry=0x147bf4000db8, table_list=0x147bf4013e20, table=table@entry=0x147bf40216a8, altered_table=altered_table@entry=0x147c940f9800, ha_alter_info=ha_alter_info@entry=0x147c940f9760, target_mdl_request=target_mdl_request@entry=0x147c940f9d50, alter_ctx=0x147c940fa8a0) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_table.cc:8145
#18 0x000056282881b680 in mysql_alter_table (thd=thd@entry=0x147bf4000db8, new_db=new_db@entry=0x147bf4005818, new_name=new_name@entry=0x147bf4005c38, create_info=create_info@entry=0x147c940fb4b0, table_list=<optimized out>, table_list@entry=0x147bf4013e20, alter_info=alter_info@entry=0x147c940fb3e0, order_num=0, order=0x0, ignore=false, if_exists=false) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_table.cc:10791
#19 0x00005628288a1a87 in Sql_cmd_alter_table::execute (this=<optimized out>, thd=0x147bf4000db8) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/structs.h:559
#20 0x0000562828744537 in mysql_execute_command (thd=thd@entry=0x147bf4000db8) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_parse.cc:6056
#21 0x0000562828729f34 in mysql_parse (thd=thd@entry=0x147bf4000db8, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x147c940fc3d0, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_parse.cc:8100
#22 0x0000562828739787 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x147bf4000db8, packet=packet@entry=0x147bf400b4a9 "ALTER TABLE t ADD INDEX kb (b),ADD INDEX kab (a,b),ALGORITHM=INPLACE", packet_length=packet_length@entry=68, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_class.h:1290
#23 0x000056282873d003 in do_command (thd=0x147bf4000db8) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_parse.cc:1370
#24 0x0000562828899d24 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x56282cf726d8, put_in_cache=put_in_cache@entry=true) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_connect.cc:1418
#25 0x000056282889a427 in handle_one_connection (arg=arg@entry=0x56282cf726d8) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_connect.cc:1312
#26 0x0000562828d53845 in pfs_spawn_thread (arg=0x56282cebc368) at /test/MDEV-25440-2-bb-10.5-release_dbg/storage/perfschema/pfs.cc:2201
#27 0x0000147c9d891609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#28 0x0000147c9d47f293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Comment by Roel Van de Paar [ 2022-02-09 ]

SET sql_mode='';
CREATE TABLE t (a INT UNSIGNED,b INT UNSIGNED,c CHAR(1),d CHAR(1),e VARCHAR(1),f VARCHAR(1),g BLOB,h BLOB,id INT,KEY(b),KEY(e)) ROW_FORMAT=REDUNDANT COLLATE=tis620_thai_nopad_ci;
INSERT INTO t VALUES (15842995496588415350,5339224446865937973,0,0,0,0,0,0,4);
INSERT INTO t VALUES (8118894032862615316,5299008984764990929,0,0,0,0,0,0,1);
SELECT GROUP_CONCAT(DISTINCT a,c ORDER BY a) FROM t;

Leads to same assert, different stack:

10.5.14 cf63eecef44f189ce2d221612dee9dfc1885ba4e (Debug)

mysqld: /test/MDEV-25440-2-bb-10.5-release_dbg/strings/ctype.c:1380: my_strnncollsp_nchars_generic_8bit: Assertion `(cs->state & 0x20000) == 0' failed.

10.5.14 cf63eecef44f189ce2d221612dee9dfc1885ba4e (Debug)

Core was generated by `/test/MDEV-25440-2-MD040222-mariadb-10.5.14-linux-x86_64-dbg/bin/mysqld --no-de'.
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 0x154c947f3700 (LWP 3027428))]
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x0000154c9dc79859 in __GI_abort () at abort.c:79
#2  0x0000154c9dc79729 in __assert_fail_base (fmt=0x154c9de0f588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x55eac866074f "(cs->state & 0x20000) == 0", file=0x55eac8660998 "/test/MDEV-25440-2-bb-10.5-release_dbg/strings/ctype.c", line=1380, function=<optimized out>) at assert.c:92
#3  0x0000154c9dc8af36 in __GI___assert_fail (assertion=assertion@entry=0x55eac866074f "(cs->state & 0x20000) == 0", file=file@entry=0x55eac8660998 "/test/MDEV-25440-2-bb-10.5-release_dbg/strings/ctype.c", line=line@entry=1380, function=function@entry=0x55eac86618c0 <__PRETTY_FUNCTION__.13851> "my_strnncollsp_nchars_generic_8bit") at assert.c:101
#4  0x000055eac7f9b4b5 in my_strnncollsp_nchars_generic_8bit (cs=<optimized out>, str1=<optimized out>, len1=<optimized out>, str2=<optimized out>, len2=<optimized out>, nchars=<optimized out>) at /test/MDEV-25440-2-bb-10.5-release_dbg/strings/ctype.c:1380
#5  0x000055eac765ef6c in Field_string::cmp (this=<optimized out>, a_ptr=<optimized out>, b_ptr=<optimized out>) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/field.h:2087
#6  0x000055eac77ba0d3 in group_concat_key_cmp_with_distinct (arg=0x154c200146c8, key1=0x154c200844a8, key2=0x154c200734e9) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/item_sum.cc:3552
#7  0x000055eac7f4df9e in tree_insert (tree=tree@entry=0x154c200180a8, key=key@entry=0x154c200734e9, key_size=key_size@entry=0, custom_arg=0x154c200146c8) at /test/MDEV-25440-2-bb-10.5-release_dbg/mysys/tree.c:248
#8  0x000055eac77c7c07 in Unique::unique_add (ptr=0x154c200734e9, this=0x154c20017f00) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/uniques.h:66
#9  Item_func_group_concat::add (this=this@entry=0x154c200146c8, exclude_nulls=true) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/item_sum.cc:4179
#10 0x000055eac77cfda6 in Item_func_group_concat::add (this=0x154c200146c8) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/item_sum.h:1976
#11 0x000055eac77c8aed in Aggregator_simple::add (this=<optimized out>) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/item_sum.h:718
#12 0x000055eac73fb409 in Item_sum::aggregator_add (this=<optimized out>) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/item_sum.h:560
#13 update_sum_func (func_ptr=0x154c20016360) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_select.cc:26002
#14 0x000055eac743aa45 in end_send_group (join=0x154c20015c38, join_tab=<optimized out>, end_of_records=<optimized out>) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_select.cc:22324
#15 0x000055eac7400315 in evaluate_join_record (join=join@entry=0x154c20015c38, join_tab=join_tab@entry=0x154c20016f78, error=error@entry=0) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_select.cc:21126
#16 0x000055eac7416703 in sub_select (join=0x154c20015c38, join_tab=0x154c20016f78, end_of_records=<optimized out>) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_select.cc:20935
#17 0x000055eac744f48e in do_select (procedure=0x0, join=0x154c20015c38) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_select.cc:20428
#18 JOIN::exec_inner (this=this@entry=0x154c20015c38) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_select.cc:4524
#19 0x000055eac744f9d8 in JOIN::exec (this=this@entry=0x154c20015c38) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_select.cc:4304
#20 0x000055eac744db5f in mysql_select (thd=thd@entry=0x154c20000db8, tables=0x154c20014c28, fields=@0x154c20013f08: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x154c20014b70, last = 0x154c20014b70, elements = 1}, <No data fields>}, conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x154c20015c10, unit=0x154c20004f60, select_lex=0x154c20013db8) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_select.cc:4781
#21 0x000055eac744de25 in handle_select (thd=thd@entry=0x154c20000db8, lex=lex@entry=0x154c20004e98, result=result@entry=0x154c20015c10, setup_tables_done_option=setup_tables_done_option@entry=0) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_select.cc:444
#22 0x000055eac73bf455 in execute_sqlcom_select (thd=thd@entry=0x154c20000db8, all_tables=0x154c20014c28) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_parse.cc:6314
#23 0x000055eac73ccbba in mysql_execute_command (thd=thd@entry=0x154c20000db8) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_parse.cc:4005
#24 0x000055eac73b7f34 in mysql_parse (thd=thd@entry=0x154c20000db8, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x154c947f23d0, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_parse.cc:8100
#25 0x000055eac73c7787 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x154c20000db8, packet=packet@entry=0x154c2000b4a9 "", packet_length=packet_length@entry=51, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_class.h:1290
#26 0x000055eac73cb003 in do_command (thd=0x154c20000db8) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_parse.cc:1370
#27 0x000055eac7527d24 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x55eacbe0b758, put_in_cache=put_in_cache@entry=true) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_connect.cc:1418
#28 0x000055eac7528427 in handle_one_connection (arg=arg@entry=0x55eacbe0b758) at /test/MDEV-25440-2-bb-10.5-release_dbg/sql/sql_connect.cc:1312
#29 0x000055eac79e1845 in pfs_spawn_thread (arg=0x55eacbd4e468) at /test/MDEV-25440-2-bb-10.5-release_dbg/storage/perfschema/pfs.cc:2201
#30 0x0000154c9e188609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#31 0x0000154c9dd76293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Comment by Roel Van de Paar [ 2022-02-09 ]

UniqueID's seen thus far

(cs->state & 0x20000) == 0|SIGABRT|my_strnncollsp_nchars_generic_8bit|Field_string::cmp|partition_info_compare_column_values|check_range_constants
(cs->state & 0x20000) == 0|SIGABRT|my_strnncollsp_nchars_generic_8bit|Field_string::cmp|group_concat_key_cmp_with_distinct|tree_insert
(cs->state & 0x20000) == 0|SIGABRT|my_strnncollsp_nchars_generic_8bit|Field_string::cmp|group_concat_key_cmp_with_order|tree_insert
(cs->state & 0x20000) == 0|SIGABRT|my_strnncollsp_nchars_generic_8bit|Field_string::cmp|Field::key_cmp|SEL_ARG::sel_cmp
(cs->state & 0x20000) == 0|SIGABRT|my_strnncollsp_nchars_generic_8bit|Field_string::cmp|Field::cmp|Cached_item_field::cm
(cs->state & 0x20000) == 0|SIGABRT|my_strnncollsp_nchars_generic_8bit|cmp_data|cmp_data_data|cmp_dfield_dfield
(cs->state & 0x20000) == 0|SIGABRT|my_strnncollsp_nchars_generic_8bit|cmp_data|cmp_dtuple_rec_with_match_low|cmp_dtuple_rec
(cs->state & 0x20000) == 0|SIGABRT|my_strnncollsp_nchars_generic_8bit|cmp_data|cmp_dfield_dfield|row_merge_tuple_cmp
(cs->state & 0x20000) == 0|SIGABRT|my_strnncollsp_nchars_generic_8bit|cmp_data|cmp_dtuple_rec_with_match_low|page_cur_search_with_match
(cs->state & 0x20000) == 0|SIGABRT|my_strnncollsp_nchars_generic_8bit|cmp_whole_field|cmp_data|cmp_dtuple_rec_with_match_low

Comment by Roel Van de Paar [ 2022-02-16 ]

CREATE TABLE t (a CHAR,b CHAR,KEY(a,b)) ROW_FORMAT=DYNAMIC COLLATE=tis620_thai_nopad_ci ENGINE=InnoDB;
INSERT INTO t VALUES (0,0);

Leads to:

10.4.23 12cad0c3468d734e041d4ef0cd5a26d2a28606fc (Debug)

mysqld: /test/10.4_dbg/strings/ctype.c:1239: my_strnncollsp_nchars_generic_8bit: Assertion `(cs->state & 0x20000) == 0' failed.

10.4.23 12cad0c3468d734e041d4ef0cd5a26d2a28606fc (Debug)

Core was generated by `/test/MD290122-mariadb-10.4.23-linux-x86_64-dbg/bin/mysqld --no-defaults --core'.
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 0x146834137700 (LWP 3834102))]
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x000014683b9e4859 in __GI_abort () at abort.c:79
#2  0x000014683b9e4729 in __assert_fail_base (fmt=0x14683bb7a588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x557fd5ae5b1b "(cs->state & 0x20000) == 0", file=0x557fd5ae6280 "/test/10.4_dbg/strings/ctype.c", line=1239, function=<optimized out>) at assert.c:92
#3  0x000014683b9f5f36 in __GI___assert_fail (assertion=assertion@entry=0x557fd5ae5b1b "(cs->state & 0x20000) == 0", file=file@entry=0x557fd5ae6280 "/test/10.4_dbg/strings/ctype.c", line=line@entry=1239, function=function@entry=0x557fd5ae6220 <__PRETTY_FUNCTION__.13584> "my_strnncollsp_nchars_generic_8bit") at assert.c:101
#4  0x0000557fd546770f in my_strnncollsp_nchars_generic_8bit (cs=<optimized out>, str1=<optimized out>, len1=<optimized out>, str2=<optimized out>, len2=<optimized out>, nchars=<optimized out>) at /test/10.4_dbg/strings/ctype.c:1239
#5  0x0000557fd506b6bc in cmp_whole_field (mtype=<optimized out>, mtype@entry=13, prtype=<optimized out>, a=a@entry=0x1467dc01ea51 "00", '\245' <repeats 13 times>, "x\352\001\334g\024", a_length=a_length@entry=1, b=b@entry=0x14681894407e "00", b_length=b_length@entry=1) at /test/10.4_dbg/storage/innobase/rem/rem0cmp.cc:329
#6  0x0000557fd506ced4 in cmp_data (len2=1, data2=0x14681894407e "00", len1=1, data1=0x1467dc01ea51 "00", '\245' <repeats 13 times>, "x\352\001\334g\024", prtype=68288766, mtype=13) at /test/10.4_dbg/storage/innobase/rem/rem0cmp.cc:401
#7  cmp_dtuple_rec_with_match_low (dtuple=dtuple@entry=0x1467dc01ff90, rec=rec@entry=0x14681894407e "00", offsets=offsets@entry=0x146834133250, n_cmp=3, matched_fields=matched_fields@entry=0x146834132af8) at /test/10.4_dbg/storage/innobase/rem/rem0cmp.cc:669
#8  0x0000557fd506d469 in cmp_dtuple_rec (dtuple=dtuple@entry=0x1467dc01ff90, rec=rec@entry=0x14681894407e "00", offsets=0x146834133250) at /test/10.4_dbg/storage/innobase/include/data0data.ic:256
#9  0x0000557fd51f1303 in page_cur_tuple_insert (cursor=cursor@entry=0x1468341330c8, tuple=tuple@entry=0x1467dc01ff90, index=index@entry=0x1467dc021a50, offsets=offsets@entry=0x146834133018, heap=heap@entry=0x146834133008, n_ext=<optimized out>, mtr=0x146834133630) at /test/10.4_dbg/storage/innobase/include/page0cur.ic:289
#10 0x0000557fd51f7213 in btr_cur_optimistic_insert (flags=flags@entry=0, cursor=cursor@entry=0x1468341330c0, offsets=offsets@entry=0x146834133018, heap=heap@entry=0x146834133008, entry=entry@entry=0x1467dc01ff90, rec=rec@entry=0x146834133070, big_rec=0x146834133160, n_ext=<optimized out>, thr=0x1467dc027b40, mtr=0x146834133630) at /test/10.4_dbg/storage/innobase/btr/btr0cur.cc:3609
#11 0x0000557fd50a9413 in row_ins_sec_index_entry_low (flags=flags@entry=0, mode=mode@entry=2, index=index@entry=0x1467dc021a50, offsets_heap=<optimized out>, offsets_heap@entry=0x1467dc06c1a0, heap=heap@entry=0x1467dc06c630, entry=entry@entry=0x1467dc01ff90, trx_id=0, thr=0x1467dc027b40) at /test/10.4_dbg/storage/innobase/row/row0ins.cc:3095
#12 0x0000557fd50af70d in row_ins_sec_index_entry (index=index@entry=0x1467dc021a50, entry=entry@entry=0x1467dc01ff90, thr=thr@entry=0x1467dc027b40, check_foreign=check_foreign@entry=true) at /test/10.4_dbg/storage/innobase/row/row0ins.cc:3297
#13 0x0000557fd50b140b in row_ins_index_entry (thr=0x1467dc027b40, entry=0x1467dc01ff90, index=0x1467dc021a50) at /test/10.4_dbg/storage/innobase/row/row0ins.cc:3345
#14 row_ins_index_entry_step (thr=0x1467dc027b40, node=0x1467dc027900) at /test/10.4_dbg/storage/innobase/row/row0ins.cc:3512
#15 row_ins (thr=0x1467dc027b40, node=0x1467dc027900) at /test/10.4_dbg/storage/innobase/row/row0ins.cc:3671
#16 row_ins_step (thr=thr@entry=0x1467dc027b40) at /test/10.4_dbg/storage/innobase/row/row0ins.cc:3821
#17 0x0000557fd50d70b1 in row_insert_for_mysql (mysql_rec=mysql_rec@entry=0x1467dc01ea50 "\374\060\060", '\245' <repeats 13 times>, "x\352\001\334g\024", prebuilt=0x1467dc0273e0, ins_mode=ROW_INS_NORMAL) at /test/10.4_dbg/storage/innobase/row/row0mysql.cc:1401
#18 0x0000557fd4f382d8 in ha_innobase::write_row (this=0x1467dc025fc8, record=0x1467dc01ea50 "\374\060\060", '\245' <repeats 13 times>, "x\352\001\334g\024") at /test/10.4_dbg/storage/innobase/handler/ha_innodb.cc:8112
#19 0x0000557fd4b86bf9 in handler::ha_write_row (this=0x1467dc025fc8, buf=0x1467dc01ea50 "\374\060\060", '\245' <repeats 13 times>, "x\352\001\334g\024") at /test/10.4_dbg/sql/handler.cc:6771
#20 0x0000557fd48798cf in write_record (thd=thd@entry=0x1467dc000d90, table=table@entry=0x1467dc025160, info=info@entry=0x1468341349b0) at /test/10.4_dbg/sql/sql_insert.cc:2072
#21 0x0000557fd488606e in mysql_insert (thd=thd@entry=0x1467dc000d90, table_list=0x1467dc013318, fields=@0x1467dc005ba0: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x557fd5e92ca0 <end_of_list>, last = 0x1467dc005ba0, elements = 0}, <No data fields>}, values_list=@0x1467dc005be8: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x1467dc013fd8, last = 0x1467dc013fd8, elements = 1}, <No data fields>}, update_fields=@0x1467dc005bd0: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x557fd5e92ca0 <end_of_list>, last = 0x1467dc005bd0, elements = 0}, <No data fields>}, update_values=@0x1467dc005bb8: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x557fd5e92ca0 <end_of_list>, last = 0x1467dc005bb8, elements = 0}, <No data fields>}, duplic=DUP_ERROR, ignore=false) at /test/10.4_dbg/sql/sql_insert.cc:1078
#22 0x0000557fd48c0cc1 in mysql_execute_command (thd=thd@entry=0x1467dc000d90) at /test/10.4_dbg/sql/sql_parse.cc:4598
#23 0x0000557fd48c8a83 in mysql_parse (thd=thd@entry=0x1467dc000d90, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x146834136490, 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:7995
#24 0x0000557fd48cb4df in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x1467dc000d90, packet=packet@entry=0x1467dc01a361 "INSERT INTO t VALUES (0,0)", packet_length=packet_length@entry=26, 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:1201
#25 0x0000557fd48cedd2 in do_command (thd=0x1467dc000d90) at /test/10.4_dbg/sql/sql_parse.cc:1373
#26 0x0000557fd4a0dcb3 in do_handle_one_connection (connect=connect@entry=0x557fd7581130) at /test/10.4_dbg/sql/sql_connect.cc:1420
#27 0x0000557fd4a0ddd2 in handle_one_connection (arg=0x557fd7581130) at /test/10.4_dbg/sql/sql_connect.cc:1316
#28 0x000014683bef3609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#29 0x000014683bae1293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

10.9.0 b5852ffbeebc3000982988383daeefb0549e058a (Debug)

mysqld: /test/10.9_dbg/strings/ctype.c:1381: my_strnncollsp_nchars_generic_8bit: Assertion `(cs->state & 0x20000) == 0' failed.

10.9.0 b5852ffbeebc3000982988383daeefb0549e058a (Debug)

Core was generated by `/test/MD140222-mariadb-10.9.0-linux-x86_64-dbg/bin/mysqld --no-defaults --core-'.
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 0x14e418154700 (LWP 3831283))]
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x000014e42e9ea859 in __GI_abort () at abort.c:79
#2  0x000014e42e9ea729 in __assert_fail_base (fmt=0x14e42eb80588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x55ef9d599fef "(cs->state & 0x20000) == 0", file=0x55ef9d59a238 "/test/10.9_dbg/strings/ctype.c", line=1381, function=<optimized out>) at assert.c:92
#3  0x000014e42e9fbf36 in __GI___assert_fail (assertion=assertion@entry=0x55ef9d599fef "(cs->state & 0x20000) == 0", file=file@entry=0x55ef9d59a238 "/test/10.9_dbg/strings/ctype.c", line=line@entry=1381, function=function@entry=0x55ef9d59b160 <__PRETTY_FUNCTION__.15161> "my_strnncollsp_nchars_generic_8bit") at assert.c:101
#4  0x000055ef9cec37fe in my_strnncollsp_nchars_generic_8bit (cs=<optimized out>, str1=<optimized out>, len1=<optimized out>, str2=<optimized out>, len2=<optimized out>, nchars=<optimized out>) at /test/10.9_dbg/strings/ctype.c:1381
#5  0x000055ef9cb283ef in cmp_data (mtype=<optimized out>, prtype=<optimized out>, descending=<optimized out>, data1=data1@entry=0x14e3c8026e69 "00", '\245' <repeats 13 times>, "\270n\002\310\343\024", len1=len1@entry=1, data2=data2@entry=0x14e41983407e "00", len2=1) at /test/10.9_dbg/storage/innobase/rem/rem0cmp.cc:305
#6  0x000055ef9cb28fd4 in cmp_dtuple_rec_with_match_low (dtuple=dtuple@entry=0x14e3c80213b8, rec=rec@entry=0x14e41983407e "00", index=index@entry=0x14e3c8023618, offsets=0x14e418151580, n_cmp=3, matched_fields=matched_fields@entry=0x14e418150e68) at /test/10.9_dbg/storage/innobase/include/dict0mem.h:1176
#7  0x000055ef9cc860ba in cmp_dtuple_rec (offsets=<optimized out>, index=0x14e3c8023618, rec=0x14e41983407e "00", dtuple=0x14e3c80213b8) at /test/10.9_dbg/storage/innobase/include/data0data.inl:253
#8  page_cur_tuple_insert (cursor=cursor@entry=0x14e4181513f8, tuple=tuple@entry=0x14e3c80213b8, index=index@entry=0x14e3c8023618, offsets=offsets@entry=0x14e418151348, heap=heap@entry=0x14e418151338, n_ext=0, mtr=0x14e418151960) at /test/10.9_dbg/storage/innobase/include/page0cur.inl:275
#9  0x000055ef9cc87c3b in btr_cur_optimistic_insert (flags=flags@entry=0, cursor=cursor@entry=0x14e4181513f0, offsets=offsets@entry=0x14e418151348, heap=heap@entry=0x14e418151338, entry=entry@entry=0x14e3c80213b8, rec=rec@entry=0x14e4181513a0, big_rec=0x14e418151490, n_ext=<optimized out>, thr=0x14e3c80282a8, mtr=0x14e418151960) at /test/10.9_dbg/storage/innobase/btr/btr0cur.cc:3546
#10 0x000055ef9cb6d425 in row_ins_sec_index_entry_low (flags=flags@entry=0, mode=mode@entry=2, index=index@entry=0x14e3c8023618, offsets_heap=<optimized out>, offsets_heap@entry=0x14e3c806d338, heap=heap@entry=0x14e3c806d7d8, entry=entry@entry=0x14e3c80213b8, trx_id=<optimized out>, thr=<optimized out>) at /test/10.9_dbg/storage/innobase/row/row0ins.cc:3130
#11 0x000055ef9cb6db98 in row_ins_sec_index_entry (index=index@entry=0x14e3c8023618, entry=entry@entry=0x14e3c80213b8, thr=thr@entry=0x14e3c80282a8, check_foreign=check_foreign@entry=true) at /test/10.9_dbg/storage/innobase/row/row0ins.cc:3331
#12 0x000055ef9cb6f796 in row_ins_index_entry (thr=0x14e3c80282a8, entry=0x14e3c80213b8, index=0x14e3c8023618) at /test/10.9_dbg/storage/innobase/row/row0ins.cc:3390
#13 row_ins_index_entry_step (thr=0x14e3c80282a8, node=0x14e3c8028078) at /test/10.9_dbg/storage/innobase/row/row0ins.cc:3556
#14 row_ins (thr=0x14e3c80282a8, node=0x14e3c8028078) at /test/10.9_dbg/storage/innobase/row/row0ins.cc:3702
#15 row_ins_step (thr=thr@entry=0x14e3c80282a8) at /test/10.9_dbg/storage/innobase/row/row0ins.cc:3848
#16 0x000055ef9cb93c58 in row_insert_for_mysql (mysql_rec=mysql_rec@entry=0x14e3c8026e68 "\374\060\060", '\245' <repeats 13 times>, "\270n\002\310\343\024", prebuilt=0x14e3c8027b58, ins_mode=ROW_INS_NORMAL) at /test/10.9_dbg/storage/innobase/row/row0mysql.cc:1318
#17 0x000055ef9ca0ef63 in ha_innobase::write_row (this=0x14e3c80272f0, record=0x14e3c8026e68 "\374\060\060", '\245' <repeats 13 times>, "\270n\002\310\343\024") at /test/10.9_dbg/storage/innobase/handler/ha_innodb.cc:7833
#18 0x000055ef9c668369 in handler::ha_write_row (this=0x14e3c80272f0, buf=0x14e3c8026e68 "\374\060\060", '\245' <repeats 13 times>, "\270n\002\310\343\024") at /test/10.9_dbg/sql/handler.cc:7522
#19 0x000055ef9c2fe372 in write_record (thd=thd@entry=0x14e3c8000db8, table=table@entry=0x14e3c8025738, info=info@entry=0x14e418152cd0, sink=sink@entry=0x0) at /test/10.9_dbg/sql/sql_insert.cc:2156
#20 0x000055ef9c30a0c8 in mysql_insert (thd=thd@entry=0x14e3c8000db8, table_list=0x14e3c8013ec0, fields=@0x14e3c8006080: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x55ef9d9999e0 <end_of_list>, last = 0x14e3c8006080, elements = 0}, <No data fields>}, values_list=@0x14e3c80060c8: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x14e3c8014b58, last = 0x14e3c8014b58, elements = 1}, <No data fields>}, update_fields=@0x14e3c80060b0: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x55ef9d9999e0 <end_of_list>, last = 0x14e3c80060b0, elements = 0}, <No data fields>}, update_values=@0x14e3c8006098: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x55ef9d9999e0 <end_of_list>, last = 0x14e3c8006098, elements = 0}, <No data fields>}, duplic=DUP_ERROR, ignore=false, result=0x0) at /test/10.9_dbg/sql/sql_insert.cc:1127
#21 0x000055ef9c35092a in mysql_execute_command (thd=thd@entry=0x14e3c8000db8, is_called_from_prepared_stmt=is_called_from_prepared_stmt@entry=false) at /test/10.9_dbg/sql/sql_parse.cc:4562
#22 0x000055ef9c33b315 in mysql_parse (thd=thd@entry=0x14e3c8000db8, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x14e418153400) at /test/10.9_dbg/sql/sql_parse.cc:8027
#23 0x000055ef9c349fb1 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x14e3c8000db8, packet=packet@entry=0x14e3c800b889 "INSERT INTO t VALUES (0,0)", packet_length=packet_length@entry=26, blocking=blocking@entry=true) at /test/10.9_dbg/sql/sql_class.h:1362
#24 0x000055ef9c34d3f8 in do_command (thd=0x14e3c8000db8, blocking=blocking@entry=true) at /test/10.9_dbg/sql/sql_parse.cc:1402
#25 0x000055ef9c4c7fc4 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x55ef9eaa1628, put_in_cache=put_in_cache@entry=true) at /test/10.9_dbg/sql/sql_connect.cc:1418
#26 0x000055ef9c4c85c9 in handle_one_connection (arg=arg@entry=0x55ef9eaa1628) at /test/10.9_dbg/sql/sql_connect.cc:1312
#27 0x000055ef9c94ed67 in pfs_spawn_thread (arg=0x55ef9e9b4848) at /test/10.9_dbg/storage/perfschema/pfs.cc:2201
#28 0x000014e42eef9609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#29 0x000014e42eae7293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Bug confirmed present in:
MariaDB: 10.4.23 (dbg), 10.9.0 (dbg)

Bug (or feature/syntax) confirmed not present in:
MariaDB: 10.2.42 (dbg), 10.2.42 (opt), 10.3.33 (dbg), 10.3.33 (opt), 10.4.23 (opt), 10.5.14 (dbg), 10.5.14 (opt), 10.6.6 (dbg), 10.6.6 (opt), 10.7.2 (dbg), 10.7.2 (opt), 10.8.1 (dbg), 10.8.1 (opt), 10.9.0 (opt)
MySQL: 5.5.62 (dbg), 5.5.62 (opt), 5.6.51 (dbg), 5.6.51 (opt), 5.7.36 (dbg), 5.7.36 (opt), 8.0.27 (dbg), 8.0.27 (opt)

Comment by Roel Van de Paar [ 2022-03-01 ]

Yet another stack with this testcase

CREATE TABLE t (a CHAR,b CHAR) COLLATE=tis620_thai_nopad_ci;
INSERT INTO t VALUES (0,0);
SELECT a,SUM(DISTINCT a),MIN(b) FROM t GROUP BY a;

Leads to:

10.9.0 4a2a9c02cd6611ef36bbb735c2b483dbc83580d4 (Debug)

mysqld: /test/10.9_dbg/strings/ctype.c:1381: my_strnncollsp_nchars_generic_8bit: Assertion `(cs->state & 0x20000) == 0' failed.

10.9.0 4a2a9c02cd6611ef36bbb735c2b483dbc83580d4 (Debug)

Core was generated by `/test/MD260222-mariadb-10.9.0-linux-x86_64-dbg/bin/mysqld --no-defaults --core-'.
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 0x1504f81fa700 (LWP 744415))]
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x000015050d2a8859 in __GI_abort () at abort.c:79
#2  0x000015050d2a8729 in __assert_fail_base (fmt=0x15050d43e588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x55b5d96c418f "(cs->state & 0x20000) == 0", file=0x55b5d96c43d8 "/test/10.9_dbg/strings/ctype.c", line=1381, function=<optimized out>) at assert.c:92
#3  0x000015050d2b9f36 in __GI___assert_fail (assertion=assertion@entry=0x55b5d96c418f "(cs->state & 0x20000) == 0", file=file@entry=0x55b5d96c43d8 "/test/10.9_dbg/strings/ctype.c", line=line@entry=1381, function=function@entry=0x55b5d96c5300 <__PRETTY_FUNCTION__.15161> "my_strnncollsp_nchars_generic_8bit") at assert.c:101
#4  0x000055b5d8fed6b2 in my_strnncollsp_nchars_generic_8bit (cs=<optimized out>, str1=<optimized out>, len1=<optimized out>, str2=<optimized out>, len2=<optimized out>, nchars=<optimized out>) at /test/10.9_dbg/strings/ctype.c:1381
#5  0x000055b5d8745416 in Field_string::cmp (this=<optimized out>, a_ptr=<optimized out>, b_ptr=<optimized out>) at /test/10.9_dbg/sql/field.h:2100
#6  0x000055b5d87c9bf4 in Field::cmp (str=<optimized out>, this=<optimized out>) at /test/10.9_dbg/sql/field.h:1281
#7  Cached_item_field::cmp (this=0x1504a0017d98) at /test/10.9_dbg/sql/item_buff.cc:197
#8  0x000055b5d84efd31 in test_if_group_changed (list=@0x1504a0015d48: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x1504a006d1a8, last = 0x1504a006d1a8, elements = 1}, <No data fields>}) at /test/10.9_dbg/sql/sql_select.cc:25695
#9  0x000055b5d84f9985 in end_send_group (join=0x1504a0015bd0, join_tab=<optimized out>, end_of_records=<optimized out>) at /test/10.9_dbg/sql/sql_select.cc:22542
#10 0x000055b5d84c012c in evaluate_join_record (join=join@entry=0x1504a0015bd0, join_tab=join_tab@entry=0x1504a0017448, error=error@entry=0) at /test/10.9_dbg/sql/sql_select.cc:21325
#11 0x000055b5d84d655b in sub_select (join=0x1504a0015bd0, join_tab=0x1504a0017448, end_of_records=<optimized out>) at /test/10.9_dbg/sql/sql_select.cc:21095
#12 0x000055b5d850e386 in do_select (procedure=0x0, join=0x1504a0015bd0) at /test/10.9_dbg/sql/sql_select.cc:20640
#13 JOIN::exec_inner (this=this@entry=0x1504a0015bd0) at /test/10.9_dbg/sql/sql_select.cc:4749
#14 0x000055b5d850e932 in JOIN::exec (this=this@entry=0x1504a0015bd0) at /test/10.9_dbg/sql/sql_select.cc:4527
#15 0x000055b5d850c941 in mysql_select (thd=thd@entry=0x1504a0000db8, tables=0x1504a0014a78, fields=@0x1504a0014140: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x1504a0014438, last = 0x1504a0014a18, elements = 3}, <No data fields>}, conds=0x0, og_num=1, order=0x0, group=0x1504a0015290, having=0x0, proc_param=0x0, select_options=2147748608, result=0x1504a0015ba8, unit=0x1504a00051c8, select_lex=0x1504a0013ea0) at /test/10.9_dbg/sql/sql_select.cc:5007
#16 0x000055b5d850cbf6 in handle_select (thd=thd@entry=0x1504a0000db8, lex=lex@entry=0x1504a00050f0, result=result@entry=0x1504a0015ba8, setup_tables_done_option=setup_tables_done_option@entry=0) at /test/10.9_dbg/sql/sql_select.cc:543
#17 0x000055b5d846c152 in execute_sqlcom_select (thd=thd@entry=0x1504a0000db8, all_tables=0x1504a0014a78) at /test/10.9_dbg/sql/sql_parse.cc:6252
#18 0x000055b5d84790b9 in mysql_execute_command (thd=thd@entry=0x1504a0000db8, is_called_from_prepared_stmt=is_called_from_prepared_stmt@entry=false) at /test/10.9_dbg/sql/sql_parse.cc:3943
#19 0x000055b5d8465343 in mysql_parse (thd=thd@entry=0x1504a0000db8, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x1504f81f9400) at /test/10.9_dbg/sql/sql_parse.cc:8027
#20 0x000055b5d8473fdf in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x1504a0000db8, packet=packet@entry=0x1504a000b889 "", packet_length=packet_length@entry=49, blocking=blocking@entry=true) at /test/10.9_dbg/sql/sql_class.h:1362
#21 0x000055b5d8477426 in do_command (thd=0x1504a0000db8, blocking=blocking@entry=true) at /test/10.9_dbg/sql/sql_parse.cc:1402
#22 0x000055b5d85f2036 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x55b5db7c08a8, put_in_cache=put_in_cache@entry=true) at /test/10.9_dbg/sql/sql_connect.cc:1418
#23 0x000055b5d85f263b in handle_one_connection (arg=arg@entry=0x55b5db7c08a8) at /test/10.9_dbg/sql/sql_connect.cc:1312
#24 0x000055b5d8a78d23 in pfs_spawn_thread (arg=0x55b5db703328) at /test/10.9_dbg/storage/perfschema/pfs.cc:2201
#25 0x000015050d7b7609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#26 0x000015050d3a5293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Bug confirmed present in:
MariaDB: 10.4.25 (dbg), 10.5.16 (dbg), 10.6.8 (dbg), 10.7.4 (dbg), 10.8.3 (dbg), 10.9.0 (dbg)

Bug (or feature/syntax) confirmed not present in:
MariaDB: 10.2.44 (dbg), 10.2.44 (opt), 10.3.35 (dbg), 10.3.35 (opt), 10.4.25 (opt), 10.5.16 (opt), 10.6.8 (opt), 10.7.4 (opt), 10.8.3 (opt), 10.9.0 (opt)
MySQL: 5.5.62 (dbg), 5.5.62 (opt), 5.6.51 (dbg), 5.6.51 (opt), 5.7.37 (dbg), 5.7.37 (opt), 8.0.28 (dbg), 8.0.28 (opt)

Comment by Roel Van de Paar [ 2022-03-09 ]

And one more differing stack with this testcase:

CREATE TABLE t (a CHAR,b CHAR,KEY(a,b)) ROW_FORMAT=DYNAMIC COLLATE=tis620_thai_nopad_ci ENGINE=InnoDB;
SET unique_checks=0,foreign_key_checks=0,autocommit=0;
INSERT INTO t VALUES (0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0);

Leads to:

10.9.0 4a2a9c02cd6611ef36bbb735c2b483dbc83580d4 (Debug)

mysqld: /test/10.9_dbg/strings/ctype.c:1381: my_strnncollsp_nchars_generic_8bit: Assertion `(cs->state & 0x20000) == 0' failed.

10.9.0 4a2a9c02cd6611ef36bbb735c2b483dbc83580d4 (Debug)

Core was generated by `/test/MD260222-mariadb-10.9.0-linux-x86_64-dbg/bin/mysqld --no-defaults --core-'.
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 0x149b963a2700 (LWP 3386051))]
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x0000149bb5a32859 in __GI_abort () at abort.c:79
#2  0x0000149bb5a32729 in __assert_fail_base (fmt=0x149bb5bc8588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x561c2e97e18f "(cs->state & 0x20000) == 0", file=0x561c2e97e3d8 "/test/10.9_dbg/strings/ctype.c", line=1381, function=<optimized out>) at assert.c:92
#3  0x0000149bb5a44006 in __GI___assert_fail (assertion=assertion@entry=0x561c2e97e18f "(cs->state & 0x20000) == 0", file=file@entry=0x561c2e97e3d8 "/test/10.9_dbg/strings/ctype.c", line=line@entry=1381, function=function@entry=0x561c2e97f300 <__PRETTY_FUNCTION__.15161> "my_strnncollsp_nchars_generic_8bit") at assert.c:101
#4  0x0000561c2e2a76b2 in my_strnncollsp_nchars_generic_8bit (cs=<optimized out>, str1=<optimized out>, len1=<optimized out>, str2=<optimized out>, len2=<optimized out>, nchars=<optimized out>) at /test/10.9_dbg/strings/ctype.c:1381
#5  0x0000561c2df0bff1 in cmp_data (mtype=<optimized out>, prtype=<optimized out>, descending=descending@entry=false, data1=0x149b58332920 "0", len1=len1@entry=1, data2=data2@entry=0x149b58332980 "0", len2=1) at /test/10.9_dbg/storage/innobase/rem/rem0cmp.cc:305
#6  0x0000561c2df5acfd in cmp_dfield_dfield (descending=<optimized out>, dfield2=0x149b58332950, dfield1=0x149b583328d8) at /test/10.9_dbg/storage/innobase/include/data0data.h:589
#7  row_merge_tuple_cmp (index=index@entry=0x149b58023618, n_uniq=n_uniq@entry=3, n_field=n_field@entry=3, a=@0x149b58132840: {fields = 0x149b583328d8}, b=@0x149b58132848: {fields = 0x149b58332938}, dup=dup@entry=0x0) at /test/10.9_dbg/storage/innobase/row/row0merge.cc:952
#8  0x0000561c2df5afe5 in row_merge_tuple_sort (index=index@entry=0x149b58023618, n_uniq=n_uniq@entry=3, n_field=n_field@entry=3, dup=dup@entry=0x0, tuples=tuples@entry=0x149b58132838, aux=aux@entry=0x149b58232838, low=1, high=3) at /test/10.9_dbg/storage/innobase/row/row0merge.cc:1028
#9  0x0000561c2df5ae56 in row_merge_tuple_sort (index=index@entry=0x149b58023618, n_uniq=n_uniq@entry=3, n_field=n_field@entry=3, dup=dup@entry=0x0, tuples=tuples@entry=0x149b58132838, aux=aux@entry=0x149b58232838, low=0, high=3) at /test/10.9_dbg/storage/innobase/row/row0merge.cc:1028
#10 0x0000561c2df5ae34 in row_merge_tuple_sort (index=0x149b58023618, n_uniq=3, n_field=3, dup=dup@entry=0x0, tuples=0x149b58132838, aux=0x149b58232838, low=0, high=7) at /test/10.9_dbg/storage/innobase/row/row0merge.cc:1028
#11 0x0000561c2df5b11d in row_merge_buf_sort (buf=buf@entry=0x149b963a0220, dup=dup@entry=0x0) at /test/10.9_dbg/storage/innobase/row/row0merge.cc:1042
#12 0x0000561c2df6715a in row_merge_bulk_t::write_to_index (this=this@entry=0x149b5806f640, index_no=index_no@entry=1, trx=trx@entry=0x149bb486b1e0) at /test/10.9_dbg/storage/innobase/row/row0merge.cc:5234
#13 0x0000561c2df67316 in row_merge_bulk_t::write_to_table (this=0x149b5806f640, table=<optimized out>, trx=trx@entry=0x149bb486b1e0) at /test/10.9_dbg/storage/innobase/row/row0merge.cc:5278
#14 0x0000561c2e01ed9f in trx_mod_table_time_t::write_bulk (trx=0x149bb486b1e0, table=<optimized out>, this=0x149b58021590) at /test/10.9_dbg/storage/innobase/include/trx0trx.h:519
#15 trx_t::bulk_insert_apply (this=<optimized out>) at /test/10.9_dbg/storage/innobase/include/trx0trx.h:1133
#16 trx_mark_sql_stat_end (trx=trx@entry=0x149bb486b1e0) at /test/10.9_dbg/storage/innobase/trx/trx0trx.cc:1630
#17 0x0000561c2dddbfa6 in innobase_commit (hton=<optimized out>, thd=0x149b58000db8, commit_trx=<optimized out>) at /test/10.9_dbg/storage/innobase/handler/ha_innodb.cc:4564
#18 0x0000561c2da3d379 in commit_one_phase_2 (thd=thd@entry=0x149b58000db8, all=all@entry=false, trans=trans@entry=0x149b58004758, is_real_trans=is_real_trans@entry=false) at /test/10.9_dbg/sql/handler.cc:2051
#19 0x0000561c2da3d691 in ha_commit_one_phase (thd=thd@entry=0x149b58000db8, all=all@entry=false) at /test/10.9_dbg/sql/handler.cc:2004
#20 0x0000561c2da51aae in ha_commit_trans (thd=thd@entry=0x149b58000db8, all=all@entry=false) at /test/10.9_dbg/sql/handler.cc:1798
#21 0x0000561c2d8c2c38 in trans_commit_stmt (thd=thd@entry=0x149b58000db8) at /test/10.9_dbg/sql/transaction.cc:472
#22 0x0000561c2d7391be in mysql_execute_command (thd=thd@entry=0x149b58000db8, is_called_from_prepared_stmt=is_called_from_prepared_stmt@entry=false) at /test/10.9_dbg/sql/sql_parse.cc:6048
#23 0x0000561c2d71f343 in mysql_parse (thd=thd@entry=0x149b58000db8, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x149b963a1400) at /test/10.9_dbg/sql/sql_parse.cc:8027
#24 0x0000561c2d72dfdf in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x149b58000db8, packet=packet@entry=0x149b5800b889 "INSERT INTO t VALUES (0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0)", packet_length=packet_length@entry=62, blocking=blocking@entry=true) at /test/10.9_dbg/sql/sql_class.h:1362
#25 0x0000561c2d731426 in do_command (thd=0x149b58000db8, blocking=blocking@entry=true) at /test/10.9_dbg/sql/sql_parse.cc:1402
#26 0x0000561c2d8ac036 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x561c308bf968, put_in_cache=put_in_cache@entry=true) at /test/10.9_dbg/sql/sql_connect.cc:1418
#27 0x0000561c2d8ac63b in handle_one_connection (arg=arg@entry=0x561c308bf968) at /test/10.9_dbg/sql/sql_connect.cc:1312
#28 0x0000561c2dd32d23 in pfs_spawn_thread (arg=0x561c307d2738) at /test/10.9_dbg/storage/perfschema/pfs.cc:2201
#29 0x0000149bb5f43609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#30 0x0000149bb5b2f163 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Bug confirmed present in:
MariaDB: 10.4.25 (dbg), 10.5.16 (dbg), 10.6.8 (dbg), 10.7.4 (dbg), 10.8.3 (dbg), 10.9.0 (dbg)

Bug (or feature/syntax) confirmed not present in:
MariaDB: 10.2.44 (dbg), 10.2.44 (opt), 10.3.35 (dbg), 10.3.35 (opt), 10.4.25 (opt),10.5.16 (opt), 10.6.8 (opt), 10.7.4 (opt), 10.8.3 (opt), 10.9.0 (opt)
MySQL: 5.5.62 (dbg), 5.5.62 (opt), 5.6.51 (dbg), 5.6.51 (opt), 5.7.37 (dbg), 5.7.37 (opt), 8.0.28 (dbg), 8.0.28 (opt)

Comment by Roel Van de Paar [ 2022-04-08 ]

Additional smaller testcase without ROW_FORMAT. Index is required.

CREATE TABLE t (a CHAR,KEY(a)) ENGINE=InnoDB COLLATE=tis620_thai_nopad_ci;
INSERT INTO t VALUES (0);

Comment by Roel Van de Paar [ 2022-08-24 ]

Additional stack with this testcase

CREATE TABLE t (a CHAR,b CHAR,KEY(a,b)) ROW_FORMAT=DYNAMIC COLLATE=tis620_thai_nopad_ci;
SET foreign_key_checks=0;
SET SESSION unique_checks=0;
INSERT IGNORE INTO t VALUES (1,0),(1,0),(0,0),(0,0),(0,0),(0,0);

Leads to:

10.11.0 bc563f1a4b0b38de3b41fd0f0d3d8b7f1aacbd8b (Debug)

mysqld: /test/10.11_dbg/strings/ctype.c:1384: my_strnncollsp_nchars_generic_8bit: Assertion `(cs->state & 0x20000) == 0' failed.

10.11.0 bc563f1a4b0b38de3b41fd0f0d3d8b7f1aacbd8b (Debug)

Core was generated by `/test/MD190822-mariadb-10.11.0-linux-x86_64-dbg/bin/mysqld --no-defaults --core'.
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 0x14ebe5f78700 (LWP 2191610))]
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x000014ec02f4b859 in __GI_abort () at abort.c:79
#2  0x000014ec02f4b729 in __assert_fail_base (fmt=0x14ec030e1588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x55c525403069 "(cs->state & 0x20000) == 0", file=0x55c5254032b0 "/test/10.11_dbg/strings/ctype.c", line=1384, function=<optimized out>) at assert.c:92
#3  0x000014ec02f5cfd6 in __GI___assert_fail (assertion=assertion@entry=0x55c525403069 "(cs->state & 0x20000) == 0", file=file@entry=0x55c5254032b0 "/test/10.11_dbg/strings/ctype.c", line=line@entry=1384, function=function@entry=0x55c5254041c0 <__PRETTY_FUNCTION__.15203> "my_strnncollsp_nchars_generic_8bit") at assert.c:101
#4  0x000055c524cde773 in my_strnncollsp_nchars_generic_8bit (cs=<optimized out>, str1=<optimized out>, len1=<optimized out>, str2=<optimized out>, len2=<optimized out>, nchars=<optimized out>) at /test/10.11_dbg/strings/ctype.c:1384
#5  0x000055c52497a69e in cmp_data (mtype=<optimized out>, prtype=<optimized out>, descending=<optimized out>, data1=data1@entry=0x14eba801eb59 "10", '\245' <repeats 13 times>, "\250\353\001\250\353\024", len1=len1@entry=1, data2=data2@entry=0x14ec00ac407e "10", len2=1) at /test/10.11_dbg/storage/innobase/rem/rem0cmp.cc:303
#6  0x000055c52497b283 in cmp_dtuple_rec_with_match_low (dtuple=dtuple@entry=0x14eba8020ed0, rec=rec@entry=0x14ec00ac407e "10", index=index@entry=0x14eba8021a60, offsets=offsets@entry=0x14ebe5f73c60, n_cmp=3, matched_fields=matched_fields@entry=0x14ebe5f73ec0) at /test/10.11_dbg/storage/innobase/include/dict0mem.h:1207
#7  0x000055c52493ec90 in page_cur_search_with_match (block=block@entry=0x14ec009dcd80, index=index@entry=0x14eba8021a60, tuple=tuple@entry=0x14eba8020ed0, mode=mode@entry=PAGE_CUR_LE, iup_matched_fields=iup_matched_fields@entry=0x14ebe5f74758, ilow_matched_fields=ilow_matched_fields@entry=0x14ebe5f74768, cursor=0x14ebe5f753f8, rtr_info=0x0) at /test/10.11_dbg/storage/innobase/include/data0data.inl:253
#8  0x000055c524ada649 in btr_cur_search_to_nth_level_func (index=index@entry=0x14eba8021a60, level=level@entry=0, tuple=tuple@entry=0x14eba8020ed0, mode=mode@entry=PAGE_CUR_LE, latch_mode=<optimized out>, latch_mode@entry=2114, cursor=cursor@entry=0x14ebe5f753f0, ahi_latch=<optimized out>, mtr=<optimized out>, autoinc=<optimized out>) at /test/10.11_dbg/storage/innobase/btr/btr0cur.cc:1943
#9  0x000055c5249b4b51 in row_ins_sec_index_entry_low (flags=flags@entry=0, mode=mode@entry=2, index=index@entry=0x14eba8021a60, offsets_heap=<optimized out>, offsets_heap@entry=0x14eba806fc10, heap=heap@entry=0x14eba80700a0, entry=entry@entry=0x14eba8020ed0, trx_id=0, thr=0x14eba8029910) at /test/10.11_dbg/storage/innobase/row/row0ins.cc:2942
#10 0x000055c5249b6aa2 in row_ins_sec_index_entry (index=index@entry=0x14eba8021a60, entry=entry@entry=0x14eba8020ed0, thr=thr@entry=0x14eba8029910, check_foreign=check_foreign@entry=true) at /test/10.11_dbg/storage/innobase/row/row0ins.cc:3251
#11 0x000055c5249bb86c in row_ins_index_entry (thr=0x14eba8029910, entry=0x14eba8020ed0, index=0x14eba8021a60) at /test/10.11_dbg/storage/innobase/row/row0ins.cc:3310
#12 row_ins_index_entry_step (thr=0x14eba8029910, node=<optimized out>) at /test/10.11_dbg/storage/innobase/row/row0ins.cc:3476
#13 row_ins (thr=0x14eba8029910, node=<optimized out>) at /test/10.11_dbg/storage/innobase/row/row0ins.cc:3622
#14 row_ins_step (thr=thr@entry=0x14eba8029910) at /test/10.11_dbg/storage/innobase/row/row0ins.cc:3762
#15 0x000055c5249dddd1 in row_insert_for_mysql (mysql_rec=mysql_rec@entry=0x14eba801eb58 "\374\061\060", '\245' <repeats 13 times>, "\250\353\001\250\353\024", prebuilt=0x14eba80291c0, ins_mode=ROW_INS_NORMAL) at /test/10.11_dbg/storage/innobase/row/row0mysql.cc:1313
#16 0x000055c52486b1e1 in ha_innobase::write_row (this=0x14eba8028970, record=0x14eba801eb58 "\374\061\060", '\245' <repeats 13 times>, "\250\353\001\250\353\024") at /test/10.11_dbg/storage/innobase/handler/ha_innodb.cc:7855
#17 0x000055c5245544b7 in handler::ha_write_row (this=0x14eba8028970, buf=0x14eba801eb58 "\374\061\060", '\245' <repeats 13 times>, "\250\353\001\250\353\024") at /test/10.11_dbg/sql/handler.cc:7577
#18 0x000055c52421360c in write_record (thd=thd@entry=0x14eba8000db8, table=table@entry=0x14eba801e258, info=info@entry=0x14ebe5f76c30, sink=sink@entry=0x0) at /test/10.11_dbg/sql/sql_insert.cc:2191
#19 0x000055c52421e188 in mysql_insert (thd=thd@entry=0x14eba8000db8, table_list=<optimized out>, fields=@0x14eba8005ea8: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x55c525825c20 <end_of_list>, last = 0x14eba8005ea8, elements = 0}, <No data fields>}, values_list=@0x14eba8005ef0: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x14eba8014a00, last = 0x14eba8015068, elements = 6}, <No data fields>}, update_fields=@0x14eba8005ed8: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x55c525825c20 <end_of_list>, last = 0x14eba8005ed8, elements = 0}, <No data fields>}, update_values=@0x14eba8005ec0: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x55c525825c20 <end_of_list>, last = 0x14eba8005ec0, elements = 0}, <No data fields>}, duplic=DUP_ERROR, ignore=true, result=0x0) at /test/10.11_dbg/sql/sql_insert.cc:1146
#20 0x000055c52426124c in mysql_execute_command (thd=thd@entry=0x14eba8000db8, is_called_from_prepared_stmt=is_called_from_prepared_stmt@entry=false) at /test/10.11_dbg/sql/sql_parse.cc:4563
#21 0x000055c52424d882 in mysql_parse (thd=thd@entry=0x14eba8000db8, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x14ebe5f77330) at /test/10.11_dbg/sql/sql_parse.cc:8035
#22 0x000055c52425ae6a in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x14eba8000db8, packet=packet@entry=0x14eba800b6e9 "INSERT IGNORE INTO t VALUES (1,0),(1,0),(0,0),(0,0),(0,0),(0,0)", packet_length=packet_length@entry=63, blocking=blocking@entry=true) at /test/10.11_dbg/sql/sql_class.h:1339
#23 0x000055c52425d574 in do_command (thd=0x14eba8000db8, blocking=blocking@entry=true) at /test/10.11_dbg/sql/sql_parse.cc:1407
#24 0x000055c5243bf1da in do_handle_one_connection (connect=<optimized out>, connect@entry=0x55c52765ec08, put_in_cache=put_in_cache@entry=true) at /test/10.11_dbg/sql/sql_connect.cc:1418
#25 0x000055c5243bf6e3 in handle_one_connection (arg=0x55c52765ec08) at /test/10.11_dbg/sql/sql_connect.cc:1312
#26 0x000014ec0345c609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#27 0x000014ec03048133 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Bug confirmed present in:
MariaDB: 10.4.27 (dbg), 10.5.18 (dbg), 10.6.10 (dbg), 10.7.6 (dbg), 10.8.5 (dbg), 10.9.2 (dbg), 10.10.2 (dbg), 10.11.0 (dbg)

Bug (or feature/syntax) confirmed not present in:
MariaDB: 10.3.37 (dbg), 10.3.37 (opt), 10.4.27 (opt), 10.5.18 (opt), 10.6.10 (opt), 10.7.6 (opt), 10.8.5 (opt), 10.9.2 (opt), 10.10.2 (opt), 10.11.0 (opt)
MySQL: 5.5.62 (dbg), 5.5.62 (opt), 5.6.51 (dbg), 5.6.51 (opt), 5.7.38 (dbg), 5.7.38 (opt), 8.0.29 (dbg), 8.0.29 (opt)

(cs->state & 0x20000) == 0|SIGABRT|my_strnncollsp_nchars_generic_8bit|cmp_data|cmp_dtuple_rec_with_match_low|page_cur_search_with_match

Comment by Alexander Barkov [ 2022-11-18 ]

A similar crash in my_strnncollsp_nchars_generic_8bit happens with this script:

CREATE OR REPLACE TABLE t1
(
  id INT NOT NULL,
  data VARCHAR(2),
  KEY data_id (data(1),id)
) COLLATE tis620_thai_nopad_ci ENGINE=MyISAM
PARTITION BY RANGE (id)
(
  PARTITION p10 VALUES LESS THAN (10),
  PARTITION p20 VALUES LESS THAN (20)
);
INSERT INTO t1 VALUES (4, 'ab'), (14, 'ab'), (19,''),(9,'') ;
SELECT id FROM t1 WHERE data='' ORDER BY id;
DROP TABLE t1;

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