Bug #112513 Assertion Failure in /mysql-8.0.34/sql/item.h:2103
Submitted: 26 Sep 2023 12:22 Modified: 26 Sep 2023 12:26
Reporter: xin wen Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: DML Severity:S6 (Debug Builds)
Version:8.0.34 OS:Ubuntu (20.04)
Assigned to: CPU Architecture:Any

[26 Sep 2023 12:22] xin wen
Description:
Run these queries:

CREATE TABLE x ( x VARCHAR ( 1 ) ) ;
 INSERT INTO x ( x ) VALUES ( 'x' ) , ( NULL ) , ( 'x' ) , ( NULL ) ;
 SELECT x FROM x WHERE NULL = x GROUP BY EXISTS ( WITH x ( x ) AS ( SELECT 1 INTERSECT SELECT CASE WHEN x >= 1 THEN ( NULL ) ELSE ( 1 * x ) END + x % 1 ^ 1 + 1 ^ 1 <= CASE WHEN 1 THEN 1.000000 IS NULL END FROM x ) SELECT 1 + 1 FROM x WHERE TRUE > 1 OR CASE x WHEN 1 THEN x WHEN x * x * 1 + x THEN 'x' ELSE 1 END != 1 OR CASE WHEN CASE WHEN 1 THEN 1 - 1 WHEN 1.000000 THEN x ELSE x END THEN 1.000000 WHEN 'x' THEN 1 WHEN 1.000000 THEN 1 / 1 WHEN 1 THEN 1 ELSE x END ^ ( TRUE ) ^ 1.000000 LIKE CASE WHEN x >= 1 THEN x < 1.000000 IS NOT NULL ELSE ( 'x' * x ) END ) HAVING x = 1 ;

Will trigger assertion failure:
mysqld: /home/wx/mysql-8.0.34/sql/item.h:2103: String* Item::null_return_str(): Assertion `m_nullable' failed.

GDB info:
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00007ffff6af2859 in __GI_abort () at abort.c:79
#2  0x00007ffff6af2729 in __assert_fail_base (fmt=0x7ffff6c88588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x55555df70300 "m_nullable", file=0x55555df6d620 "/home/wx/mysql-8.0.34/sql/item.h", line=2103, function=<optimized out>) at assert.c:92
#3  0x00007ffff6b03fd6 in __GI___assert_fail (assertion=assertion@entry=0x55555df70300 "m_nullable", file=file@entry=0x55555df6d620 "/home/wx/mysql-8.0.34/sql/item.h", line=line@entry=2103, function=function@entry=0x55555df702c0 "String* Item::null_return_str()") at assert.c:101
#4  0x0000555559ccaab7 in Item::null_return_str (this=this@entry=0x613000dabcf0) at /home/wx/mysql-8.0.34/sql/item.h:2105
#5  0x0000555559ca4f96 in Item_func_case::val_str (this=0x613000dabcf0, str=<optimized out>) at /home/wx/mysql-8.0.34/sql/item_cmpfunc.cc:3706
#6  0x0000555559ccb05a in eval_string_arg (to_cs=to_cs@entry=0x555560d342c0 <my_charset_latin1>, arg=0x613000dabcf0, buffer=buffer@entry=0x6150003aeca0) at /home/wx/mysql-8.0.34/sql/item_func.h:97
#7  0x0000555559ca90c2 in Item_func_like::val_int (this=0x6150003aeb30) at /home/wx/mysql-8.0.34/sql/item_cmpfunc.cc:6253
#8  0x0000555559c36dab in Item::val_bool (this=0x6150003aeb30) at /home/wx/mysql-8.0.34/sql/item.cc:217
#9  0x0000555559cb95e7 in Item_cond_or::val_int (this=0x6120003361f0) at /home/wx/mysql-8.0.34/sql/item_cmpfunc.cc:5981
#10 0x000055555a293a03 in FilterIterator::Read (this=0x60700039d2b0) at /home/wx/mysql-8.0.34/sql/iterators/composite_iterators.cc:79
#11 0x000055555a29eefb in MaterializeIterator<DummyIteratorProfiler>::MaterializeQueryBlock (this=this@entry=0x611000125db0, query_block=..., stored_rows=stored_rows@entry=0x7fffc7063630) at /home/wx/mysql-8.0.34/sql/iterators/composite_iterators.cc:1170
#12 0x000055555a2a5500 in MaterializeIterator<DummyIteratorProfiler>::Init (this=0x611000125db0) at /home/wx/mysql-8.0.34/sql/iterators/composite_iterators.cc:928
#13 0x00005555597138da in Query_expression::ExecuteIteratorQuery (this=this@entry=0x612000312df0, thd=thd@entry=0x6270002bf900) at /home/wx/mysql-8.0.34/sql/sql_union.cc:1763
#14 0x0000555559713ecd in Query_expression::execute (this=this@entry=0x612000312df0, thd=thd@entry=0x6270002bf900) at /home/wx/mysql-8.0.34/sql/sql_union.cc:1823
#15 0x000055555a1be107 in Table_ref::materialize_derived (this=this@entry=0x61b0006644b0, thd=thd@entry=0x6270002bf900) at /home/wx/mysql-8.0.34/sql/sql_derived.cc:1705
#16 0x000055555a1be664 in Table_ref::optimize_derived (this=this@entry=0x61b0006644b0, thd=<optimized out>) at /home/wx/mysql-8.0.34/sql/sql_derived.cc:1589
#17 0x000055555949240d in JOIN::optimize (this=0x6190005596b0, finalize_access_paths=finalize_access_paths@entry=false) at /home/wx/mysql-8.0.34/sql/sql_optimizer.cc:405
#18 0x00005555595b28b0 in Query_block::optimize (this=this@entry=0x6190005316b0, thd=thd@entry=0x6270002bf900, finalize_access_paths=finalize_access_paths@entry=false) at /home/wx/mysql-8.0.34/sql/sql_select.cc:2013
#19 0x0000555559714de9 in Query_expression::optimize (this=this@entry=0x612000312c70, thd=thd@entry=0x6270002bf900, materialize_destination=materialize_destination@entry=0x0, create_iterators=create_iterators@entry=false, finalize_access_paths=finalize_access_paths@entry=false) at /home/wx/mysql-8.0.34/sql/sql_union.cc:1006
#20 0x0000555559e3243d in Item_subselect::exec (this=this@entry=0x6120003130f0, thd=0x6270002bf900) at /home/wx/mysql-8.0.34/sql/item_subselect.cc:674
#21 0x0000555559e1eac1 in Item_exists_subselect::val_bool (this=0x6120003130f0) at /home/wx/mysql-8.0.34/sql/item_subselect.cc:1606
#22 0x0000555559e1bc2a in Item_exists_subselect::val_str (this=0x6120003130f0, str=0x7fffc7064d30) at /home/wx/mysql-8.0.34/sql/item_subselect.cc:1581
#23 0x00005555594562bd in JOIN::remove_const (this=this@entry=0x6190005591b0, first_order=<optimized out>, cond=<optimized out>, change=<optimized out>, simple_order=0x6190005593b8, group_by=group_by@entry=true) at /home/wx/mysql-8.0.34/sql/sql_optimizer.cc:10170
#24 0x000055555948483c in JOIN::optimize_distinct_group_order (this=this@entry=0x6190005591b0) at /home/wx/mysql-8.0.34/sql/sql_optimizer.cc:1606
#25 0x0000555559494c49 in JOIN::optimize (this=0x6190005591b0, finalize_access_paths=finalize_access_paths@entry=true) at /home/wx/mysql-8.0.34/sql/sql_optimizer.cc:794
#26 0x00005555595b28b0 in Query_block::optimize (this=this@entry=0x61900052d0b0, thd=thd@entry=0x6270002bf900, finalize_access_paths=finalize_access_paths@entry=true) at /home/wx/mysql-8.0.34/sql/sql_select.cc:2013
#27 0x0000555559714de9 in Query_expression::optimize (this=this@entry=0x6120003103f0, thd=thd@entry=0x6270002bf900, materialize_destination=materialize_destination@entry=0x0, create_iterators=create_iterators@entry=true, finalize_access_paths=finalize_access_paths@entry=true) at /home/wx/mysql-8.0.34/sql/sql_union.cc:1006
#28 0x00005555595b1ee9 in Sql_cmd_dml::execute_inner (this=0x60b000155d80, thd=0x6270002bf900) at /home/wx/mysql-8.0.34/sql/sql_select.cc:1007 
#29 0x00005555595ce209 in Sql_cmd_dml::execute (this=0x60b000155d80, thd=0x6270002bf900) at /home/wx/mysql-8.0.34/sql/sql_select.cc:793
#30 0x00005555594bd568 in mysql_execute_command (thd=thd@entry=0x6270002bf900, first_level=first_level@entry=true) at /home/wx/mysql-8.0.34/sql/sql_parse.cc:4719
#31 0x00005555594c0bfe in dispatch_sql_command (thd=0x6270002bf900, parser_state=parser_state@entry=0x7fffc7068c00) at /home/wx/mysql-8.0.34/sql/sql_parse.cc:5368
#32 0x00005555594c38e2 in dispatch_command (thd=thd@entry=0x6270002bf900, com_data=com_data@entry=0x7fffc706a200, command=<optimized out>) at /home/wx/mysql-8.0.34/sql/sql_parse.cc:2054
#33 0x00005555594c7392 in do_command (thd=thd@entry=0x6270002bf900) at /home/wx/mysql-8.0.34/sql/sql_parse.cc:1439
#34 0x000055555989b7be in handle_connection (arg=arg@entry=0x60300016cae0) at /home/wx/mysql-8.0.34/sql/conn_handler/connection_handler_per_thread.cc:302
#35 0x000055555cc724e9 in pfs_spawn_thread (arg=0x614000140a60) at /home/wx/mysql-8.0.34/storage/perfschema/pfs.cc:3042
#36 0x00007ffff7568609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#37 0x00007ffff6bef133 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

How to repeat:
Run the queries above.
[26 Sep 2023 12:26] MySQL Verification Team
Hello xin wen,

Thank you for the report and test case.
Observed that 8.0.34 debug build is affected.

regards,
Umesh