Bug #112480 Assertion Failure in /mysql-8.0.34/sql/handler.cc:2966
Submitted: 26 Sep 2023 10:31 Modified: 26 Sep 2023 14:06
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 10:31] xin wen
Description:
Run these queries:

CREATE TABLE t0 ( c21 BOOL ) ;
INSERT INTO t0 VALUES ( 84 ) , ( 67 ) ;
CREATE INDEX i0 ON t0 ( c21 ) ;
INSERT INTO t0 VALUES ( 111 ) , ( -124 ) ;
SELECT t3 . c21 AS c33 FROM ( SELECT FORMAT ( 18 , 6720516515493625017 ) AS c61 ) AS t1 JOIN ( SELECT c21 AS c50 FROM t0 ) AS t2 ON c50 = c50 LEFT OUTER JOIN t0 AS t3 ON EXISTS ( WITH t4 AS ( SELECT -73 AS c9 , -44 AS c24 WHERE -1 < 122 AND -50 < -16 GROUP BY c50 WITH ROLLUP ) SELECT t1 . c61 AS c4 FROM t4 CROSS JOIN t4 AS t5 WHERE NULL > RAND ( ) - REPLACE ( t2 . c50 , RAND ( ) IN ( RAND ( ) ) , 'd"S~' ) ) ;

Will trigger assertion failure:
/home/wx/mysql-8.0.34/sql/handler.cc:2966: int handler::ha_rnd_next(uchar*): Assertion `inited == RND' 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=0x55555df45e40 "inited == RND", file=0x55555df41c40 "/home/wx/mysql-8.0.34/sql/handler.cc", line=2966, function=<optimized out>) at assert.c:92
#3  0x00007ffff6b03fd6 in __GI___assert_fail (assertion=assertion@entry=0x55555df45e40 "inited == RND", file=file@entry=0x55555df41c40 "/home/wx/mysql-8.0.34/sql/handler.cc", line=line@entry=2966, function=function@entry=0x55555df45ec0 "int handler::ha_rnd_next(uchar*)") at assert.c:101
#4  0x0000555559b9dc27 in handler::ha_rnd_next (this=0x62200037b130, buf=<optimized out>) at /home/wx/mysql-8.0.34/sql/handler.cc:2971
#5  0x0000555559ecb34b in TableScanIterator::Read (this=0x60c0001726f0) at /home/wx/mysql-8.0.34/sql/iterators/basic_row_iterators.cc:219
#6  0x000055555a29b198 in MaterializeIterator<DummyIteratorProfiler>::Read (this=0x611000113570) at /home/wx/mysql-8.0.34/sql/iterators/composite_iterators.cc:1413
#7  0x000055555a295732 in NestedLoopIterator::Read (this=0x608000ede8d0) at /home/wx/mysql-8.0.34/sql/iterators/composite_iterators.cc:471
#8  0x000055555a295732 in NestedLoopIterator::Read (this=0x608000ede950) at /home/wx/mysql-8.0.34/sql/iterators/composite_iterators.cc:471
#9  0x000055555a295918 in NestedLoopIterator::Read (this=0x608000ede9d0) at /home/wx/mysql-8.0.34/sql/iterators/composite_iterators.cc:494
#10 0x0000555559713b95 in Query_expression::ExecuteIteratorQuery (this=this@entry=0x6120002fddf0, thd=thd@entry=0x6270002bf900) at /home/wx/mysql-8.0.34/sql/sql_union.cc:1770
#11 0x0000555559713ecd in Query_expression::execute (this=this@entry=0x6120002fddf0, thd=thd@entry=0x6270002bf900) at /home/wx/mysql-8.0.34/sql/sql_union.cc:1823
#12 0x00005555595b1f79 in Sql_cmd_dml::execute_inner (this=0x60b00015d520, thd=0x6270002bf900) at /home/wx/mysql-8.0.34/sql/sql_select.cc:1022
#13 0x00005555595ce209 in Sql_cmd_dml::execute (this=0x60b00015d520, thd=0x6270002bf900) at /home/wx/mysql-8.0.34/sql/sql_select.cc:793
#14 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
#15 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
#16 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
#17 0x00005555594c7392 in do_command (thd=thd@entry=0x6270002bf900) at /home/wx/mysql-8.0.34/sql/sql_parse.cc:1439
#18 0x000055555989b7be in handle_connection (arg=arg@entry=0x603000165310) at /home/wx/mysql-8.0.34/sql/conn_handler/connection_handler_per_thread.cc:302
#19 0x000055555cc724e9 in pfs_spawn_thread (arg=0x614000140a60) at /home/wx/mysql-8.0.34/storage/perfschema/pfs.cc:3042
#20 0x00007ffff7568609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#21 0x00007ffff6bef133 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

How to repeat:
Run the queries above.
[26 Sep 2023 14:06] 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 14:07] MySQL Verification Team
./mtr --nocheck-testcases bug112480 --debug-server
Logging: ./mtr  --nocheck-testcases bug112480 --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 ( c21 BOOL ) ;
INSERT INTO t0 VALUES ( 84 ) , ( 67 ) ;
CREATE INDEX i0 ON t0 ( c21 ) ;
INSERT INTO t0 VALUES ( 111 ) , ( -124 ) ;
SELECT t3 . c21 AS c33 FROM ( SELECT FORMAT ( 18 , 6720516515493625017 ) AS c61 ) AS t1 JOIN ( SELECT c21 AS c50 FROM t0 ) AS t2 ON c50 = c50 LEFT OUTER JOIN t0 AS t3 ON EXISTS ( WITH t4 AS ( SELECT -73 AS c9 , -44 AS c24 WHERE -1 < 122 AND -50 < -16 GROUP BY c50 WITH ROLLUP ) SELECT t1 . c61 AS c4 FROM t4 CROSS JOIN t4 AS t5 WHERE NULL > RAND ( ) - REPLACE ( t2 . c50 , RAND ( ) IN ( RAND ( ) ) , 'd"S~' ) ) ;
[ 50%] main.bug112480                            [ fail ]
        Test ended at 2023-09-26 16:06:48

CURRENT_TEST: main.bug112480
mysqltest: At line 5: Query 'SELECT t3 . c21 AS c33 FROM ( SELECT FORMAT ( 18 , 6720516515493625017 ) AS c61 ) AS t1 JOIN ( SELECT c21 AS c50 FROM t0 ) AS t2 ON c50 = c50 LEFT OUTER JOIN t0 AS t3 ON EXISTS ( WITH t4 AS ( SELECT -73 AS c9 , -44 AS c24 WHERE -1 < 122 AND -50 < -16 GROUP BY c50 WITH ROLLUP ) SELECT t1 . c61 AS c4 FROM t4 CROSS JOIN t4 AS t5 WHERE NULL > RAND ( ) - REPLACE ( t2 . c50 , RAND ( ) IN ( RAND ( ) ) , 'd"S~' ) ) ' failed.
ERROR 2013 (HY000): Lost connection to MySQL server during query
safe_process[6843]: Child process: 6844, exit: 1

-bt
Thread 1 (Thread 0x7f03341f7700 (LWP 6850)):
#0  0x00007f035581eaa1 in pthread_kill () from /lib64/libpthread.so.0
#1  0x000000000402c28e in my_write_core(int) ()
#2  0x00000000032d235e in handle_fatal_signal ()
#3  <signal handler called>
#4  0x00007f0353b69387 in raise () from /lib64/libc.so.6
#5  0x00007f0353b6aa78 in abort () from /lib64/libc.so.6
#6  0x00007f0353b621a6 in __assert_fail_base () from /lib64/libc.so.6
#7  0x00007f0353b62252 in __assert_fail () from /lib64/libc.so.6
#8  0x00000000033de8c9 in handler::ha_rnd_next(unsigned char*) ()
#9  0x00000000034ff92a in TableScanIterator::Read() ()
#10 0x0000000003669356 in MaterializeIterator<DummyIteratorProfiler>::Read() ()
#11 0x00000000036674a4 in NestedLoopIterator::Read() ()
#12 0x00000000036674a4 in NestedLoopIterator::Read() ()
#13 0x000000000366752f in NestedLoopIterator::Read() ()
#14 0x000000000322d193 in Query_expression::ExecuteIteratorQuery(THD*) ()
#15 0x000000000322d2aa in Query_expression::execute(THD*) ()
#16 0x00000000031b71dc in Sql_cmd_dml::execute_inner(THD*) ()
#17 0x00000000031c0beb in Sql_cmd_dml::execute(THD*) ()
#18 0x0000000003161263 in mysql_execute_command(THD*, bool) ()
#19 0x00000000031626a2 in dispatch_sql_command(THD*, Parser_state*) ()
#20 0x0000000003163cd5 in dispatch_command(THD*, COM_DATA const*, enum_server_command) ()
#21 0x000000000316596c in do_command(THD*) ()
#22 0x00000000032c437c in handle_connection ()
#23 0x00000000047e1af5 in pfs_spawn_thread ()
#24 0x00007f0355819ea5 in start_thread () from /lib64/libpthread.so.0
#25 0x00007f0353c31b2d in clone () from /lib64/libc.so.6