Bug #112462 Assertion Failure in home/wx/mysql-8.0.34/sql/sql_derived.cc:1641

Submitted: 26 Sep 2023 8:58 Modified: 26 Sep 2023 9:03
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 8:58] xin wen
Description:
Run these queries:

CREATE TABLE t0 ( c0 DECIMAL ( 19 ) DEFAULT ( -95 ) ) ;
INSERT INTO t0 VALUES ( -10 ) , ( -118 ) ;
ALTER TABLE t0 ADD COLUMN c29 INT AFTER c0 ;
INSERT INTO t0 VALUES ( -6 , 52 ) , ( 58 , 85 ) ;
SELECT t3 . c49 AS c53 FROM ( SELECT CONCAT ( ( CONCAT_WS ( -103 , '>5~\\9' , '`nLDnE' ) ) = -63 IS NULL = 57 ) * ( WITH RECURSIVE t1 ( c63 ) AS ( SELECT 1 AS c63 UNION SELECT c29 + 22 AS c32 FROM t1 WHERE c29 < 4 AND c0 < -40 AND c29 < 34 AND c29 < 67 AND c63 < 78 AND c0 < -1271988362172968189 AND c0 < -71 AND c29 < 101 AND c63 < 115 ) SELECT c63 AS c55 FROM t1 CROSS JOIN t0 AS t2 WHERE t1 . c63 = 113 GROUP BY c63 , c29 LIMIT 1 ) AS c49 FROM t0 ) AS t3 JOIN t0 ON t0 . c0 = t0 . c0 GROUP BY c0 , c49 HAVING STDDEV_SAMP( t0 . c0 ) ;

Will trigger assertion failure:
/home/wx/mysql-8.0.34/sql/sql_derived.cc:1641: bool Table_ref::create_materialized_table(THD*): Assertion `(common_table_expr() != nullptr && common_table_expr()->references.size() > 1) || tab == nullptr || tab->type() != JT_CONST || table->has_null_row()' 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=0x55555e0b2460 "(common_table_expr() != nullptr && common_table_expr()->references.size() > 1) || tab == nullptr || tab->type() != JT_CONST || table->has_null_row()", file=0x55555e0b3d20 "/home/wx/mysql-8.0.34/sql/sql_derived.cc", line=1641, function=<optimized out>) at assert.c:92
#3  0x00007ffff6b03fd6 in __GI___assert_fail ( assertion=assertion@entry=0x55555e0b2460 "(common_table_expr() != nullptr && common_table_expr()->references.size() > 1) || tab == nullptr || tab->type() != JT_CONST || table->has_null_row()", file=file@entry=0x55555e0b3d20 "/home/wx/mysql-8.0.34/sql/sql_derived.cc", line=line@entry=1641, function=function@entry=0x55555e0b2320 "bool Table_ref::create_materialized_table(THD*)") at assert.c:101
#4  0x000055555a1bdb7b in Table_ref::create_materialized_table (this=this@entry=0x61b000491eb0, thd=<optimized out>) at /home/wx/mysql-8.0.34/sql/sql_derived.cc:1650
#5  0x000055555a2a4fc7 in MaterializeIterator<DummyIteratorProfiler>::Init (this=0x611000072170) at /home/wx/mysql-8.0.34/sql/iterators/composite_iterators.cc:843
#6  0x000055555a2b1c37 in HashJoinIterator::Init (this=0x621000303530) at /home/wx/mysql-8.0.34/sql/iterators/hash_join_iterator.cc:182
#7  0x000055555a29dc26 in MaterializeIterator<DummyIteratorProfiler>::MaterializeQueryBlock (this=this@entry=0x6110000722b0, query_block=..., stored_rows=stored_rows@entry=0x7fffdc7b4520) at /home/wx/mysql-8.0.34/sql/iterators/composite_iterators.cc:1109
#8  0x000055555a2a5500 in MaterializeIterator<DummyIteratorProfiler>::Init (this=0x6110000722b0) at /home/wx/mysql-8.0.34/sql/iterators/composite_iterators.cc:928
#9  0x000055555a293b23 in LimitOffsetIterator::Init (this=0x60c0000a1a70) at /home/wx/mysql-8.0.34/sql/iterators/composite_iterators.cc:100
#10 0x00005555597138da in Query_expression::ExecuteIteratorQuery (this=this@entry=0x6120000cb8f0, thd=thd@entry=0x6270000ab900) at /home/wx/mysql-8.0.34/sql/sql_union.cc:1763
#11 0x0000555559713ecd in Query_expression::execute (this=this@entry=0x6120000cb8f0, thd=thd@entry=0x6270000ab900) at /home/wx/mysql-8.0.34/sql/sql_union.cc:1823
#12 0x0000555559e1f26d in SubqueryWithResult::exec (this=<optimized out>, thd=thd@entry=0x6270000ab900) at /home/wx/mysql-8.0.34/sql/item_subselect.cc:3062
#13 0x0000555559e32301 in Item_subselect::exec (this=this@entry=0x6120000cb470, thd=0x6270000ab900) at /home/wx/mysql-8.0.34/sql/item_subselect.cc:695
#14 0x0000555559e1c543 in Item_singlerow_subselect::val_real (this=0x6120000cb470) at /home/wx/mysql-8.0.34/sql/item_subselect.cc:1230
#15 0x0000555559d4d78a in Item_func_mul::real_op (this=0x6120000bdf70) at /home/wx/mysql-8.0.34/sql/item_func.cc:2262
#16 0x0000555559d427c9 in Item_func_numhybrid::val_real (this=0x6120000bdf70) at /home/wx/mysql-8.0.34/sql/item_func.cc:1698
#17 0x0000555559c66065 in Item::save_in_field_inner (this=0x6120000bdf70, field=0x6120000c9af0, no_conversions=<optimized out>) at /home/wx/mysql-8.0.34/sql/item.cc:6748
#18 0x00005555593ff0ba in Item::save_in_field_no_error_check (this=this@entry=0x6120000bdf70, field=0x6120000c9af0, no_conversions=no_conversions@entry=true) at /home/wx/mysql-8.0.34/sql/item.h:1321
#19 0x00005555593e753c in copy_funcs (param=<optimized out>, thd=<optimized out>, type=type@entry=CFT_ALL) at /home/wx/mysql-8.0.34/sql/sql_executor.cc:436
#20 0x000055555a29e05b in MaterializeIterator<DummyIteratorProfiler>::MaterializeQueryBlock (this=this@entry=0x611000071db0, query_block=..., stored_rows=stored_rows@entry=0x7fffdc7b57f0) at /home/wx/mysql-8.0.34/sql/iterators/composite_iterators.cc:1170
#21 0x000055555a2a5500 in MaterializeIterator<DummyIteratorProfiler>::Init (this=0x611000071db0) at /home/wx/mysql-8.0.34/sql/iterators/composite_iterators.cc:928
#22 0x000055555a2b0b58 in HashJoinIterator::InitProbeIterator (this=this@entry=0x62100015a530) at /home/wx/mysql-8.0.34/sql/iterators/hash_join_iterator.cc:138
#23 0x000055555a2b2435 in HashJoinIterator::Init (this=0x62100015a530) at /home/wx/mysql-8.0.34/sql/iterators/hash_join_iterator.cc:263
#24 0x000055555a2a198e in TemptableAggregateIterator<DummyIteratorProfiler>::Init (this=0x60c0000a1d70) at /home/wx/mysql-8.0.34/sql/iterators/composite_iterators.cc:1674
#25 0x0000555559f04c9b in FilterIterator::Init (this=<optimized out>) at /home/wx/mysql-8.0.34/sql/iterators/composite_iterators.h:83
#26 0x00005555597138da in Query_expression::ExecuteIteratorQuery (this=this@entry=0x612000071470, thd=thd@entry=0x6270000ab900) at /home/wx/mysql-8.0.34/sql/sql_union.cc:1763
#27 0x0000555559713ecd in Query_expression::execute (this=this@entry=0x612000071470, thd=thd@entry=0x6270000ab900) at /home/wx/mysql-8.0.34/sql/sql_union.cc:1823
#28 0x00005555595b1f79 in Sql_cmd_dml::execute_inner (this=0x60b00011e800, thd=0x6270000ab900) at /home/wx/mysql-8.0.34/sql/sql_select.cc:1022
#29 0x00005555595ce209 in Sql_cmd_dml::execute (this=0x60b00011e800, thd=0x6270000ab900) at /home/wx/mysql-8.0.34/sql/sql_select.cc:793
#30 0x00005555594bd568 in mysql_execute_command (thd=thd@entry=0x6270000ab900, 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=0x6270000ab900, parser_state=parser_state@entry=0x7fffdc7b8c00) at /home/wx/mysql-8.0.34/sql/sql_parse.cc:5368
#32 0x00005555594c38e2 in dispatch_command (thd=thd@entry=0x6270000ab900, com_data=com_data@entry=0x7fffdc7ba200, command=<optimized out>) at /home/wx/mysql-8.0.34/sql/sql_parse.cc:2054
#33 0x00005555594c7392 in do_command (thd=thd@entry=0x6270000ab900) at /home/wx/mysql-8.0.34/sql/sql_parse.cc:1439
#34 0x000055555989b7be in handle_connection (arg=arg@entry=0x603000166630) 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

Observed that only debug build is affected.

How to repeat:
Run the queries above.
[26 Sep 2023 9:03] 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
[26 Sep 2023 9:04] MySQL Verification Team
-- 8.0.34

./mtr --nocheck-testcases bug112462
Logging: ./mtr  --nocheck-testcases bug112462
MySQL Version 8.0.34
Checking supported features
Using 'all' suites
Collecting tests
Checking leftover processes
Removing old var directory
Creating var directory '/export/home/tmp/ushastry/mysql-8.0.34/mysql-test/var'
Installing system database
Using parallel: 1

==============================================================================
                  TEST NAME                       RESULT  TIME (ms) COMMENT
------------------------------------------------------------------------------
CREATE TABLE t0 ( c0 DECIMAL ( 19 ) DEFAULT ( -95 ) ) ;
INSERT INTO t0 VALUES ( -10 ) , ( -118 ) ;
ALTER TABLE t0 ADD COLUMN c29 INT AFTER c0 ;
INSERT INTO t0 VALUES ( -6 , 52 ) , ( 58 , 85 ) ;
SELECT t3 . c49 AS c53 FROM ( SELECT CONCAT ( ( CONCAT_WS ( -103 , '>5~\\9' , '`nLDnE' ) ) = -63 IS NULL = 57 ) * ( WITH RECURSIVE t1 ( c63 ) AS ( SELECT 1 AS c63 UNION SELECT c29 + 22 AS c32 FROM t1 WHERE c29 < 4 AND c0 < -40 AND c29 < 34 AND c29 < 67 AND c63 < 78 AND c0 < -1271988362172968189 AND c0 < -71 AND c29 < 101 AND c63 < 115 ) SELECT c63 AS c55 FROM t1 CROSS JOIN t0 AS t2 WHERE t1 . c63 = 113 GROUP BY c63 , c29 LIMIT 1 ) AS c49 FROM t0 ) AS t3 JOIN t0 ON t0 . c0 = t0 . c0 GROUP BY c0 , c49 HAVING STDDEV_SAMP( t0 . c0 ) ;
c53
[ 50%] main.bug112462                            [ pass ]    105
[100%] shutdown_report                           [ pass ]

-- debug build

 ./mtr --nocheck-testcases bug112462 --debug-server
Logging: ./mtr  --nocheck-testcases bug112462 --debug-server
MySQL Version 8.0.34
Checking supported features
 - Binaries are debug compiled
Using 'all' suites
Collecting tests
Checking leftover processes
Removing old var directory
Creating var directory '/export/home/tmp/ushastry/mysql-8.0.34/mysql-test/var'
Installing system database
Using parallel: 1

==============================================================================
                  TEST NAME                       RESULT  TIME (ms) COMMENT
------------------------------------------------------------------------------
CREATE TABLE t0 ( c0 DECIMAL ( 19 ) DEFAULT ( -95 ) ) ;
INSERT INTO t0 VALUES ( -10 ) , ( -118 ) ;
ALTER TABLE t0 ADD COLUMN c29 INT AFTER c0 ;
INSERT INTO t0 VALUES ( -6 , 52 ) , ( 58 , 85 ) ;
SELECT t3 . c49 AS c53 FROM ( SELECT CONCAT ( ( CONCAT_WS ( -103 , '>5~\\9' , '`nLDnE' ) ) = -63 IS NULL = 57 ) * ( WITH RECURSIVE t1 ( c63 ) AS ( SELECT 1 AS c63 UNION SELECT c29 + 22 AS c32 FROM t1 WHERE c29 < 4 AND c0 < -40 AND c29 < 34 AND c29 < 67 AND c63 < 78 AND c0 < -1271988362172968189 AND c0 < -71 AND c29 < 101 AND c63 < 115 ) SELECT c63 AS c55 FROM t1 CROSS JOIN t0 AS t2 WHERE t1 . c63 = 113 GROUP BY c63 , c29 LIMIT 1 ) AS c49 FROM t0 ) AS t3 JOIN t0 ON t0 . c0 = t0 . c0 GROUP BY c0 , c49 HAVING STDDEV_SAMP( t0 . c0 ) ;
[ 50%] main.bug112462                            [ fail ]
        Test ended at 2023-09-26 11:02:39

CURRENT_TEST: main.bug112462
mysqltest: At line 5: Query 'SELECT t3 . c49 AS c53 FROM ( SELECT CONCAT ( ( CONCAT_WS ( -103 , '>5~\\9' , '`nLDnE' ) ) = -63 IS NULL = 57 ) * ( WITH RECURSIVE t1 ( c63 ) AS ( SELECT 1 AS c63 UNION SELECT c29 + 22 AS c32 FROM t1 WHERE c29 < 4 AND c0 < -40 AND c29 < 34 AND c29 < 67 AND c63 < 78 AND c0 < -1271988362172968189 AND c0 < -71 AND c29 < 101 AND c63 < 115 ) SELECT c63 AS c55 FROM t1 CROSS JOIN t0 AS t2 WHERE t1 . c63 = 113 GROUP BY c63 , c29 LIMIT 1 ) AS c49 FROM t0 ) AS t3 JOIN t0 ON t0 . c0 = t0 . c0 GROUP BY c0 , c49 HAVING STDDEV_SAMP( t0 . c0 ) ' failed.
ERROR 2013 (HY000): Lost connection to MySQL server during query

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.056 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.