Bug #112499 Assertion Failure in /mysql-8.0.34/sql/sql_tmp_table.cc:485
Submitted: 26 Sep 2023 11:37 Modified: 26 Sep 2023 11:48
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 11:37] xin wen
Description:
Run these queries:

CREATE TABLE t0 ( c26 INT , c12 INT ) ;
INSERT INTO t0 VALUES ( DEFAULT , DEFAULT ) , ( DEFAULT , DEFAULT ) ;
ALTER TABLE t0 ALTER COLUMN c26 DROP DEFAULT ;
INSERT INTO t0 VALUES ( -113 , 126 ) , ( 26 , -110 ) ;
SELECT t0 . c12 IN ( SELECT 61 AS c22 UNION DISTINCT SELECT CONCAT_WS ( c26 , '1h7\'^z*k"}:HtDy>CBn27' , 'q0@ qoHetPE%' ) AS c16 FROM t0 GROUP BY c12 , c26 , c26 , c12 WITH ROLLUP HAVING GROUP_CONCAT( c56 , -105 ORDER BY RAND ( ) AND t1 . c56 = t0 . c12 IS TRUE SEPARATOR 'KUl$+7P4FEM,,Ea"u"&5^i3P&LJ%aPKJY4dA1are)%rU(wD mq' ) ) AS c32 FROM ( SELECT DEGREES ( 953555588265499464 ) = ALL ( SELECT c12 AS c53 FROM t0 ) AS c56 FROM t0 ) AS t1 JOIN t0 ON t1 . c56 = t0 . c12 ORDER BY RAND ( ) * RAND ( ) , c32 , c32 IS NOT UNKNOWN ;

Will trigger assertion failure:
/home/wx/mysql-8.0.34/sql/sql_tmp_table.cc:485: Field* create_tmp_field(THD*, TABLE*, Item*, Item::Type, Func_ptr_array*, Field**, Field**, bool, bool, bool, bool): Assertion `*from_field' 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=0x55555ddbe7a0 "*from_field", file=0x55555ddbc1a8 "/home/wx/mysql-8.0.34/sql/sql_tmp_table.cc", line=485, function=<optimized out>) at assert.c:92
#3  0x00007ffff6b03fd6 in __GI___assert_fail (assertion=assertion@entry=0x55555ddbe7a0 "*from_field", file=file@entry=0x55555ddbc1a8 "/home/wx/mysql-8.0.34/sql/sql_tmp_table.cc", line=line@entry=485, function=function@entry=0x55555ddbe6a0 "Field* create_tmp_field(THD*, TABLE*, Item*, Item::Type, Func_ptr_array*, Field**, Field**, bool, bool, bool, bool)") at assert.c:101
#4  0x00005555596e71dc in create_tmp_field (thd=thd@entry=0x6270002bf900, table=table@entry=0x61e000249cb0, item=<optimized out>, item@entry=0x6120002edbf0, type=<optimized out>, type@entry=Item::REF_ITEM, copy_func=<optimized out>, from_field=from_field@entry=0x60700038e220, default_field=<optimized out>, group=<optimized out>, modify_item=<optimized out>, table_cant_handle_bit_fields=<optimized out>, make_copy_field=<optimized out>) at /home/wx/mysql-8.0.34/sql/sql_tmp_table.cc:488
#5  0x00005555596ecff3 in create_tmp_table (thd=thd@entry=0x6270002bf900, param=0x61000003e870, fields=..., group=<optimized out>, group@entry=0x0, distinct=<optimized out>, distinct@entry=false, save_sum_fields=<optimized out>, save_sum_fields@entry=true, select_options=<optimized out>, rows_limit=<optimized out>, table_alias=<optimized out>) at /home/wx/mysql-8.0.34/sql/sql_tmp_table.cc:1135
#6  0x0000555559e6981e in Item_func_group_concat::setup (this=0x61a00046feb0, thd=<optimized out>) at /home/wx/mysql-8.0.34/sql/item_sum.cc:4572
#7  0x0000555559e72470 in Aggregator_simple::setup (this=<optimized out>, thd=<optimized out>) at /home/wx/mysql-8.0.34/sql/item_sum.h:921
#8  0x0000555559e723a8 in Item_sum::aggregator_setup (this=<optimized out>, thd=<optimized out>) at /home/wx/mysql-8.0.34/sql/item_sum.h:664
#9  0x0000555559e57a5a in Item_rollup_sum_switcher::aggregator_setup (this=0x613000e018f0, thd=0x6270002bf900) at /home/wx/mysql-8.0.34/sql/item_sum.cc:6388
#10 0x00005555593e0096 in setup_sum_funcs (thd=0x6270002bf900, func_ptr=0x60d000ab7d78) at /home/wx/mysql-8.0.34/sql/sql_executor.cc:391
#11 0x00005555595ca525 in JOIN::make_tmp_tables_info (this=this@entry=0x6190005492b0) at /home/wx/mysql-8.0.34/sql/sql_select.cc:4717
#12 0x0000555559495da4 in JOIN::optimize (this=0x6190005492b0, finalize_access_paths=finalize_access_paths@entry=true) at /home/wx/mysql-8.0.34/sql/sql_optimizer.cc:1021
#13 0x00005555595b28b0 in Query_block::optimize (this=this@entry=0x6190005398b0, thd=thd@entry=0x6270002bf900, finalize_access_paths=finalize_access_paths@entry=true) at /home/wx/mysql-8.0.34/sql/sql_select.cc:2013
#14 0x0000555559714de9 in Query_expression::optimize (this=this@entry=0x6120002ff770, thd=thd@entry=0x6270002bf900, materialize_destination=materialize_destination@entry=0x0, create_iterators=create_iterators@entry=false, finalize_access_paths=finalize_access_paths@entry=true) at /home/wx/mysql-8.0.34/sql/sql_union.cc:1006
#15 0x00005555595b296b in Query_block::optimize (this=this@entry=0x6190005352b0, thd=thd@entry=0x6270002bf900, finalize_access_paths=finalize_access_paths@entry=true) at /home/wx/mysql-8.0.34/sql/sql_select.cc:2021
#16 0x0000555559714de9 in Query_expression::optimize (this=this@entry=0x6120002ff170, 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
#17 0x00005555595b1ee9 in Sql_cmd_dml::execute_inner (this=0x60b000157e80, thd=0x6270002bf900) at /home/wx/mysql-8.0.34/sql/sql_select.cc:1007
#18 0x00005555595ce209 in Sql_cmd_dml::execute (this=0x60b000157e80, thd=0x6270002bf900) at /home/wx/mysql-8.0.34/sql/sql_select.cc:793
#19 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
#20 0x00005555594c0bfe in dispatch_sql_command (thd=0x6270002bf900, parser_state=parser_state@entry=0x7fffc7078c00) at /home/wx/mysql-8.0.34/sql/sql_parse.cc:5368
#21 0x00005555594c38e2 in dispatch_command (thd=thd@entry=0x6270002bf900, com_data=com_data@entry=0x7fffc707a200, command=<optimized out>) at /home/wx/mysql-8.0.34/sql/sql_parse.cc:2054
#22 0x00005555594c7392 in do_command (thd=thd@entry=0x6270002bf900) at /home/wx/mysql-8.0.34/sql/sql_parse.cc:1439
#23 0x000055555989b7be in handle_connection (arg=arg@entry=0x603000163ab0) at /home/wx/mysql-8.0.34/sql/conn_handler/connection_handler_per_thread.cc:302
#24 0x000055555cc724e9 in pfs_spawn_thread (arg=0x614000140a60) at /home/wx/mysql-8.0.34/storage/perfschema/pfs.cc:3042 
#25 0x00007ffff7568609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#26 0x00007ffff6bef133 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

How to repeat:
Run the queries above.
[26 Sep 2023 11:48] 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