Bug #112514 Assertion Failure in /mysql-8.0.34/sql/sql_lex.cc:2288
Submitted: 26 Sep 2023 12:23 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:23] xin wen
Description:
Run these queries:

CREATE TABLE x ( x LONGTEXT ) ;
 INSERT INTO x ( x ) VALUES ( 'x' ) , ( NULL ) , ( 'x' ) , ( NULL ) ;
 SELECT 'x' , 1 , - ( SELECT x FROM x WHERE x = 1 AND x = 1 GROUP BY x HAVING x NOT IN ( 1 , 1 ) AND 1 NOT IN ( 1 , 1 ) AND x NOT IN ( 1 , ( SELECT 1.000000 AS x GROUP BY x NOT IN ( 1 , 1 ) AND ( ( x OR NOT x ) BETWEEN 1 AND 1 ) / x NOT IN ( CASE WHEN 'x' THEN 1.000000 END * ( SELECT 1 ) BETWEEN ( SELECT 1 AS x WHERE ( SELECT x AS x WHERE 1 > x ) ) AND x , 1 ) UNION SELECT 1.000000 ORDER BY 1 ) + 1 ) AND x NOT IN ( CASE WHEN x >= 1 THEN ( 1 * x ) END , 1 ) AND x = 1 ) >= 1 , CASE WHEN x = x OR x = 'x' THEN NOT EXISTS ( SELECT 1 FROM x WHERE ( NOT EXISTS ( SELECT 1 FROM x WHERE ( CASE 'x' WHEN - ( x NOT IN ( 'x' ) AND x NOT IN ( NOT x > x % x % 1 ) ) THEN FALSE WHEN 1 = 1 THEN x >= 'x' / 1.000000 ^ 1.000000 WHEN 1 = 1 THEN 1 ELSE 1 END , NULL BETWEEN ( SELECT x FROM x WHERE x = 1 AND x < 1 GROUP BY - 'x' >= x ) AND 1 ) NOT IN ( SELECT x , x FROM x WHERE ( SELECT x AS x FROM x WHERE 1 = x UNION SELECT 1 WHERE ( x , x ) NOT IN ( SELECT x , x FROM x ) ORDER BY ( x = 1 AND x = 1 ) DESC LIMIT 1 OFFSET 1 ) ) ) , x ) NOT IN ( SELECT x , x FROM x WHERE x > 1 ) ) AND NOT x ELSE x END FROM x GROUP BY x ;

Will trigger assertion failure:
mysqld: /home/wx/mysql-8.0.34/sql/sql_lex.cc:2288: void Query_expression::exclude_tree(): Assertion `sl->join == nullptr || is_executed()' 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=0x55555dd04360 "sl->join == nullptr || is_executed()", file=0x55555dd02740 "/home/wx/mysql-8.0.34/sql/sql_lex.cc", line=2288, function=<optimized out>) at assert.c:92
#3  0x00007ffff6b03fd6 in __GI___assert_fail (assertion=assertion@entry=0x55555dd04360 "sl->join == nullptr || is_executed()", file=file@entry=0x55555dd02740 "/home/wx/mysql-8.0.34/sql/sql_lex.cc", line=line@entry=2288, function=function@entry=0x55555dd04300 "void Query_expression::exclude_tree()") at assert.c:101
#4  0x0000555559429f62 in Query_expression::exclude_tree (this=0x6120003220f0) at /home/wx/mysql-8.0.34/sql/sql_lex.cc:2314
#5  0x0000555559e2381a in Item_subselect::clean_up_after_removal (this=0x612000322570, arg=<optimized out>) at /home/wx/mysql-8.0.34/sql/item_subselect.cc:2700
#6  0x0000555559e1ba3d in Item_subselect::walk (this=<optimized out>, processor=<optimized out>, walk=<optimized out>, arg=<optimized out>) at /home/wx/mysql-8.0.34/sql/item_subselect.cc:609
#7  0x0000555559d3e19a in Item_func::walk (this=<optimized out>, processor=&virtual table offset 776, walk=<optimized out>, argument=<optimized out>) at /home/wx/mysql-8.0.34/sql/item_func.cc:617
#8  0x0000555559d3e19a in Item_func::walk (this=<optimized out>, processor=&virtual table offset 776, walk=<optimized out>, argument=<optimized out>) at /home/wx/mysql-8.0.34/sql/item_func.cc:617
#9  0x0000555559cb8b17 in Item_cond::walk (this=<optimized out>, processor=&virtual table offset 776, walk=<optimized out>, arg=<optimized out>) at /home/wx/mysql-8.0.34/sql/item_cmpfunc.cc:5729
#10 0x00005555594369ed in Query_block::walk (this=<optimized out>, processor=&virtual table offset 776, walk=walk@entry=7, arg=arg@entry=0x7fffc706a1b0 "") at /home/wx/mysql-8.0.34/sql/sql_lex.cc:4718
#11 0x000055555970ac6e in Query_expression::walk (this=<optimized out>, processor=&virtual table offset 776, walk=walk@entry=7, arg=arg@entry=0x7fffc706a1b0 "") at /home/wx/mysql-8.0.34/sql/sql_union.cc:1987
#12 0x0000555559e1baec in Item_subselect::walk (this=<optimized out>, processor=<optimized out>, walk=<optimized out>, arg=<optimized out>) at /home/wx/mysql-8.0.34/sql/item_subselect.cc:609
#13 0x0000555559d3e19a in Item_func::walk (this=<optimized out>, processor=&virtual table offset 776, walk=<optimized out>, argument=<optimized out>) at /home/wx/mysql-8.0.34/sql/item_func.cc:617
#14 0x0000555559d3e19a in Item_func::walk (this=<optimized out>, processor=&virtual table offset 776, walk=<optimized out>, argument=<optimized out>) at /home/wx/mysql-8.0.34/sql/item_func.cc:617
#15 0x0000555559cc8f23 in Item_cond::fix_fields (this=0x613000da0df0, thd=<optimized out>, ref=<optimized out>) at /home/wx/mysql-8.0.34/sql/item_cmpfunc.cc:5606
#16 0x000055555958d42f in Query_block::prepare (this=this@entry=0x6190005366b0, thd=thd@entry=0x6270002bf900, insert_field_list=insert_field_list@entry=0x0) at /home/wx/mysql-8.0.34/sql/sql_resolver.cc:322
#17 0x000055555970ff37 in Query_expression::prepare (this=this@entry=0x6120003217f0, thd=thd@entry=0x6270002bf900, sel_result=<optimized out>, insert_field_list=insert_field_list@entry=0x0, added_options=added_options@entry=268435456, removed_options=removed_options@entry=0) at /home/wx/mysql-8.0.34/sql/sql_union.cc:753
#18 0x0000555559e1f1d8 in SubqueryWithResult::prepare (this=0x6080017401d0, thd=thd@entry=0x6270002bf900) at /home/wx/mysql-8.0.34/sql/item_subselect.cc:2971
#19 0x0000555559e31605 in Item_subselect::fix_fields (this=0x612000322e70, thd=0x6270002bf900, ref=<optimized out>) at /home/wx/mysql-8.0.34/sql/item_subselect.cc:547
#20 0x0000555559d5166d in Item_func::fix_func_arg (this=this@entry=0x612000320770, thd=thd@entry=0x6270002bf900, arg=arg@entry=0x612000320818) at /home/wx/mysql-8.0.34/sql/item_func.cc:429
#21 0x0000555559d51c48 in Item_func::fix_fields (this=0x612000320770, thd=0x6270002bf900) at /home/wx/mysql-8.0.34/sql/item_func.cc:418
#22 0x0000555559d5166d in Item_func::fix_func_arg (this=this@entry=0x6150003ae130, thd=thd@entry=0x6270002bf900, arg=arg@entry=0x6150003ae1d8) at /home/wx/mysql-8.0.34/sql/item_func.cc:429
#23 0x0000555559d51c48 in Item_func::fix_fields (this=0x6150003ae130, thd=0x6270002bf900) at /home/wx/mysql-8.0.34/sql/item_func.cc:418
#24 0x00005555592cdd7d in setup_fields (thd=thd@entry=0x6270002bf900, want_privilege=<optimized out>, allow_sum_func=allow_sum_func@entry=true, split_sum_funcs=split_sum_funcs@entry=true, column_update=column_update@entry=false, typed_items=typed_items@entry=0x0, fields=<optimized out>, ref_item_array=...) at /home/wx/mysql-8.0.34/sql/sql_base.cc:9016
#25 0x000055555958ccf7 in Query_block::prepare (this=this@entry=0x61900052d0b0, thd=thd@entry=0x6270002bf900, insert_field_list=insert_field_list@entry=0x0) at /home/wx/mysql-8.0.34/sql/sql_resolver.cc:279
#26 0x00005555595b0c63 in Sql_cmd_select::prepare_inner (this=0x60b0001570c0, thd=0x6270002bf900) at /home/wx/mysql-8.0.34/sql/sql_select.cc:650
#27 0x00005555595cd20b in Sql_cmd_dml::prepare (this=0x60b0001570c0, thd=0x6270002bf900) at /home/wx/mysql-8.0.34/sql/sql_select.cc:566
#28 0x00005555595cda8d in Sql_cmd_dml::execute (this=0x60b0001570c0, thd=0x6270002bf900) at /home/wx/mysql-8.0.34/sql/sql_select.cc:718
#29 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
#30 0x00005555594c0bfe in dispatch_sql_command (thd=0x6270002bf900, parser_state=parser_state@entry=0x7fffc706ec00) at /home/wx/mysql-8.0.34/sql/sql_parse.cc:5368
#31 0x00005555594c38e2 in dispatch_command (thd=thd@entry=0x6270002bf900, com_data=com_data@entry=0x7fffc7070200, command=<optimized out>) at /home/wx/mysql-8.0.34/sql/sql_parse.cc:2054
#32 0x00005555594c7392 in do_command (thd=thd@entry=0x6270002bf900) at /home/wx/mysql-8.0.34/sql/sql_parse.cc:1439
#33 0x000055555989b7be in handle_connection (arg=arg@entry=0x60300016b040) at /home/wx/mysql-8.0.34/sql/conn_handler/connection_handler_per_thread.cc:302
#34 0x000055555cc724e9 in pfs_spawn_thread (arg=0x614000140a60) at /home/wx/mysql-8.0.34/storage/perfschema/pfs.cc:3042
#35 0x00007ffff7568609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#36 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