Bug #112770 Assertion `!thd->is_error()' failed in MySQL 8.1.0
Submitted: 19 Oct 2023 7:41 Modified: 19 Oct 2023 7:59
Reporter: Wang Ke Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: DML Severity:S6 (Debug Builds)
Version:8.1.0, 8.0.34 OS:Any
Assigned to: CPU Architecture:Any
Tags: assertion failure

[19 Oct 2023 7:41] Wang Ke
Description:
Hello, MySQL Verification Team, an assertion failure occurred in MySQL 8.1.0 debug build:

```
2023-10-19T07:35:04.531551Z 0 [System] [MY-010931] [Server] /home/mysql-8.1.0-origin/bin/mysqld: ready for connections. Version: '8.1.0-debug-asan'  socket: '/tmp/mysql.sock'  port: 3306  Source distribution.
mysqld: /home/mysql-8.1.0/sql/sql_select.cc:586: virtual bool Sql_cmd_dml::prepare(THD *): Assertion `thd->is_error()' failed.
2023-10-19T07:36:04Z UTC - mysqld got signal 6 ;
Most likely, you have hit a bug, but this error can also be caused by malfunctioning hardware.
BuildID[sha1]=d41d0359075d9acaf807cea3acc3b128cdec5219
Thread pointer: 0x6270002bc100
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
stack_bottom = 7f9f351a4a20 thread_stack 0x100000
/home/mysql-8.1.0-origin/bin/mysqld(__interceptor_backtrace+0x5b) [0x649134b]
/home/mysql-8.1.0-origin/bin/mysqld(my_print_stacktrace(unsigned char const*, unsigned long)+0x10d) [0xbfde8ed]
/home/mysql-8.1.0-origin/bin/mysqld(print_fatal_signal(int)+0x552) [0x8979ee2]
/home/mysql-8.1.0-origin/bin/mysqld(handle_fatal_signal+0x175) [0x897a5c5]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x11390) [0x7f9f66b39390]
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0x38) [0x7f9f64e22438]
/lib/x86_64-linux-gnu/libc.so.6(abort+0x16a) [0x7f9f64e2403a]
/lib/x86_64-linux-gnu/libc.so.6(+0x2dbe7) [0x7f9f64e1abe7]
/lib/x86_64-linux-gnu/libc.so.6(+0x2dc92) [0x7f9f64e1ac92]
/home/mysql-8.1.0-origin/bin/mysqld(Sql_cmd_dml::prepare(THD*)+0x178f) [0x82ba9bf]
/home/mysql-8.1.0-origin/bin/mysqld(Sql_cmd_dml::execute(THD*)+0x97b) [0x82bc8cb]
/home/mysql-8.1.0-origin/bin/mysqld(mysql_execute_command(THD*, bool)+0x5331) [0x80a0a91]
/home/mysql-8.1.0-origin/bin/mysqld(dispatch_sql_command(THD*, Parser_state*)+0x1b28) [0x8094e68]
/home/mysql-8.1.0-origin/bin/mysqld(dispatch_command(THD*, COM_DATA const*, enum_server_command)+0x377a) [0x808522a]
/home/mysql-8.1.0-origin/bin/mysqld(do_command(THD*)+0x12ee) [0x80902be]
/home/mysql-8.1.0-origin/bin/mysqld() [0x88ff832]
/home/mysql-8.1.0-origin/bin/mysqld() [0xeb1629a]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x76ba) [0x7f9f66b2f6ba]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x6d) [0x7f9f64ef451d]

Trying to get some variables.
Some pointers may be invalid and cause the dump to abort.
Query (60c00013beb0): INSERT IGNORE INTO t0 VALUES ( ( VALUES ROW ( 1 ) , ROW ( 1 ) ) )
Connection ID (thread ID): 8
Status: NOT_KILLED

The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains
information that should help you find out what is causing the crash.

```

Observed that release build is not crashed, but don't know if control flow has been affected.

How to repeat:
Test case:

```
CREATE TABLE t0(c0 TIME);
INSERT IGNORE INTO t0 VALUES ( ( VALUES ROW ( 1 ) , ROW ( 1 ) ) ) ;
```
[19 Oct 2023 7:42] Wang Ke
assertion failure in DML module.
[19 Oct 2023 7:59] MySQL Verification Team
Hello Wang Ke,

Thank you for the report and test case.
Observed that 8.0.34 debug build is affected with provided test case.

regards,
Umesh
[19 Oct 2023 8:00] MySQL Verification Team
-- release build - not affected

./mtr --nocheck-testcases bug112770
Logging: ./mtr  --nocheck-testcases bug112770
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 TIME);
INSERT IGNORE INTO t0 VALUES ( ( VALUES ROW ( 1 ) , ROW ( 1 ) ) ) ;
[ 50%] main.bug112770                            [ pass ]     82
[100%] shutdown_report                           [ pass ]
------------------------------------------------------------------------------

-- debug build affected

 ./mtr --nocheck-testcases bug112770 --debug-server
Logging: ./mtr  --nocheck-testcases bug112770 --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 TIME);
INSERT IGNORE INTO t0 VALUES ( ( VALUES ROW ( 1 ) , ROW ( 1 ) ) ) ;
[ 50%] main.bug112770                            [ fail ]
        Test ended at 2023-10-19 09:59:28

CURRENT_TEST: main.bug112770
mysqltest: At line 2: Query 'INSERT IGNORE INTO t0 VALUES ( ( VALUES ROW ( 1 ) , ROW ( 1 ) ) ) ' failed.
ERROR 2013 (HY000): Lost connection to MySQL server during query

-bt
#0  0x00007fb787252aa1 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  0x00007fb78559d387 in raise () from /lib64/libc.so.6
#5  0x00007fb78559ea78 in abort () from /lib64/libc.so.6
#6  0x00007fb7855961a6 in __assert_fail_base () from /lib64/libc.so.6
#7  0x00007fb785596252 in __assert_fail () from /lib64/libc.so.6
#8  0x00000000031c06f5 in Sql_cmd_dml::prepare(THD*) ()
#9  0x00000000031c08ed in Sql_cmd_dml::execute(THD*) ()
#10 0x000000000315edb4 in mysql_execute_command(THD*, bool) ()
#11 0x00000000031626a2 in dispatch_sql_command(THD*, Parser_state*) ()
#12 0x0000000003163cd5 in dispatch_command(THD*, COM_DATA const*, enum_server_command) ()
#13 0x000000000316596c in do_command(THD*) ()
#14 0x00000000032c437c in handle_connection ()
#15 0x00000000047e1af5 in pfs_spawn_thread ()
#16 0x00007fb78724dea5 in start_thread () from /lib64/libpthread.so.0
#17 0x00007fb785665b2d in clone () from /lib64/libc.so.6