Bug #112498 Assertion Failure in /mysql-8.0.34/sql/sql_resolver.cc:183
Submitted: 26 Sep 2023 11:35 Modified: 3 Jan 2024 17:34
Reporter: xin wen Email Updates:
Status: Closed 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 11:35] xin wen
Description:
Run these queries:

CREATE TABLE t0 ( c42 INT , INDEX i0 ( ( CHAR_LENGTH ( 4203963951406165520 ) ) ) ) ;
INSERT INTO t0 VALUES ( DEFAULT ) , ( DEFAULT ) ;
ALTER TABLE t0 ALTER COLUMN c42 DROP DEFAULT ;
INSERT INTO t0 VALUES ( 95 ) , ( 73 ) ;
SELECT * FROM ( SELECT c42 AS c6 FROM t0 ) AS t1 JOIN t0 ON t0 . c42 = t0 . c42 WHERE c6 < -22 AND c6 < -4998443573219516447 AND c6 < -3 AND c6 < 41 GROUP BY c6 , c42 HAVING COUNT( c42 ) % ( SELECT MIN( c6 ) AS c44 FROM t0 GROUP BY c6 , c6 , c6 , c6 , c6 , c42 WITH ROLLUP HAVING t1 . c6 = ~ ( SELECT RAND ( ) << VARIANCE( c42 ) % LAST_VALUE ( c6 ) OVER ( PARTITION BY MIN( c42 ) , MAKE_SET ( 62 , 'M' , 'S9sbC3N1:B]k6c"A' ) NOT IN ( CONVERT ( t1 . c6 , UNSIGNED ) ^ TAN ( t1 . c6 ) = t1 . c6 ) ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS c17 FROM t0 GROUP BY c42 , c42 , c6 LIMIT 1 ) LIMIT 1 ) ;

Will trigger assertion failure:
/home/wx/mysql-8.0.34/sql/sql_resolver.cc:183: bool Query_block::prepare(THD*, mem_root_deque<Item*>*): Assertion `!thd->is_error()' 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=0x55555dd7cf60 "!thd->is_error()", file=0x55555dd7e4c0 "/home/wx/mysql-8.0.34/sql/sql_resolver.cc", line=183, function=<optimized out>) at assert.c:92
#3  0x00007ffff6b03fd6 in __GI___assert_fail (assertion=assertion@entry=0x55555dd7cf60 "!thd->is_error()", file=file@entry=0x55555dd7e4c0 "/home/wx/mysql-8.0.34/sql/sql_resolver.cc", line=line@entry=183, function=function@entry=0x55555dd7dd80 "bool Query_block::prepare(THD*, mem_root_deque<Item*>*)") at assert.c:101
#4  0x000055555958c5be in Query_block::prepare (this=this@entry=0x6190005401b0, thd=thd@entry=0x6270002bf900, insert_field_list=insert_field_list@entry=0x0) at /home/wx/mysql-8.0.34/sql/sql_resolver.cc:213
#5  0x000055555970ff37 in Query_expression::prepare (this=this@entry=0x6120002ee070, 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
#6  0x0000555559e1f1d8 in SubqueryWithResult::prepare (this=0x6080012809d0, thd=thd@entry=0x6270002bf900) at /home/wx/mysql-8.0.34/sql/item_subselect.cc:2971
#7  0x0000555559e31605 in Item_subselect::fix_fields (this=0x6120002ee670, thd=0x6270002bf900, ref=<optimized out>) at /home/wx/mysql-8.0.34/sql/item_subselect.cc:547
#8  0x0000555559d5166d in Item_func::fix_func_arg (this=this@entry=0x6120002ed8f0, thd=thd@entry=0x6270002bf900, arg=arg@entry=0x6120002ed998) at /home/wx/mysql-8.0.34/sql/item_func.cc:429
#9  0x0000555559d51c48 in Item_func::fix_fields (this=0x6120002ed8f0, thd=0x6270002bf900) at /home/wx/mysql-8.0.34/sql/item_func.cc:418
#10 0x0000555559d5166d in Item_func::fix_func_arg (this=this@entry=0x6150003dde30, thd=thd@entry=0x6270002bf900, arg=arg@entry=0x6150003ddee0) at /home/wx/mysql-8.0.34/sql/item_func.cc:429
#11 0x0000555559d51c48 in Item_func::fix_fields (this=0x6150003dde30, thd=0x6270002bf900) at /home/wx/mysql-8.0.34/sql/item_func.cc:418
#12 0x000055555958d42f in Query_block::prepare (this=this@entry=0x61900053edb0, thd=thd@entry=0x6270002bf900, insert_field_list=insert_field_list@entry=0x0) at /home/wx/mysql-8.0.34/sql/sql_resolver.cc:322
#13 0x000055555970ff37 in Query_expression::prepare (this=this@entry=0x6120002edd70, 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
#14 0x0000555559e1f1d8 in SubqueryWithResult::prepare (this=0x608001280ad0, thd=thd@entry=0x6270002bf900) at /home/wx/mysql-8.0.34/sql/item_subselect.cc:2971
#15 0x0000555559e31605 in Item_subselect::fix_fields (this=0x6120002ee7f0, thd=0x6270002bf900, ref=<optimized out>) at /home/wx/mysql-8.0.34/sql/item_subselect.cc:547
#16 0x0000555559d5166d in Item_func::fix_func_arg (this=this@entry=0x6120002eda70, thd=thd@entry=0x6270002bf900, arg=arg@entry=0x6120002edb20) at /home/wx/mysql-8.0.34/sql/item_func.cc:429
#17 0x0000555559d51c48 in Item_func::fix_fields (this=0x6120002eda70, thd=0x6270002bf900) at /home/wx/mysql-8.0.34/sql/item_func.cc:418
#18 0x0000555559d5166d in Item_func::fix_func_arg (this=this@entry=0x6150003de0b0, thd=thd@entry=0x6270002bf900, arg=arg@entry=0x6150003de160) at /home/wx/mysql-8.0.34/sql/item_func.cc:429
#19 0x0000555559d51c48 in Item_func::fix_fields (this=0x6150003de0b0, thd=0x6270002bf900) at /home/wx/mysql-8.0.34/sql/item_func.cc:418
#20 0x000055555958d42f in Query_block::prepare (this=this@entry=0x619000538eb0, thd=thd@entry=0x6270002bf900, insert_field_list=insert_field_list@entry=0x0) at /home/wx/mysql-8.0.34/sql/sql_resolver.cc:322
#21 0x00005555595b0c63 in Sql_cmd_select::prepare_inner (this=0x60b000158980, thd=0x6270002bf900) at /home/wx/mysql-8.0.34/sql/sql_select.cc:650
#22 0x00005555595cd20b in Sql_cmd_dml::prepare (this=0x60b000158980, thd=0x6270002bf900) at /home/wx/mysql-8.0.34/sql/sql_select.cc:566
#23 0x00005555595cda8d in Sql_cmd_dml::execute (this=0x60b000158980, thd=0x6270002bf900) at /home/wx/mysql-8.0.34/sql/sql_select.cc:718 
#24 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
#25 0x00005555594c0bfe in dispatch_sql_command (thd=0x6270002bf900, parser_state=parser_state@entry=0x7fffc707ec00) at /home/wx/mysql-8.0.34/sql/sql_parse.cc:5368
#26 0x00005555594c38e2 in dispatch_command (thd=thd@entry=0x6270002bf900, com_data=com_data@entry=0x7fffc7080200, command=<optimized out>) at /home/wx/mysql-8.0.34/sql/sql_parse.cc:2054
#27 0x00005555594c7392 in do_command (thd=thd@entry=0x6270002bf900) at /home/wx/mysql-8.0.34/sql/sql_parse.cc:1439
#28 0x000055555989b7be in handle_connection (arg=arg@entry=0x603000169a80) at /home/wx/mysql-8.0.34/sql/conn_handler/connection_handler_per_thread.cc:302
#29 0x000055555cc724e9 in pfs_spawn_thread (arg=0x614000140a60) at /home/wx/mysql-8.0.34/storage/perfschema/pfs.cc:3042
#30 0x00007ffff7568609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#31 0x00007ffff6bef133 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

How to repeat:
Run the queries above.
[26 Sep 2023 11:47] 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
[3 Jan 2024 17:34] Jon Stephens
Documented fix as follows in the MySQL 8.3.0 changelog:

    Removed an assertion in sql/sql_resolver.cc.

Closed.