Bug #107733 Assertion in ft_init_boolean_search() failed in MySQL 8.0.29
Submitted: 2 Jul 10:02 Modified: 4 Jul 6:13
Reporter: Wang Ke Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Optimizer Severity:S6 (Debug Builds)
Version:8.0.29 OS:Any
Assigned to: CPU Architecture:Any
Tags: assertion failure

[2 Jul 10:02] Wang Ke
Description:
An assertion failure occurred in mysql-8.0.29-debug-asan:

```
2022-07-02T06:40:53.537072Z 0 [System] [MY-010931] [Server] /home/mysql-server/mysql-8.0.29-origin-dev/bin/mysqld: ready for connections. Version: '8.0.29-debug-asan'  socket: '/tmp/mysql.sock'  port: 3306  Source distribution.
mysqld: /home/mysql-server/mysql-8.0.29-origin/storage/myisam/ft_boolean_search.cc:527: FT_INFO *ft_init_boolean_search(MI_INFO *, uint, uchar *, uint, const CHARSET_INFO *): Assertion `keynr == NO_SUCH_KEY || cs == info->s->keyinfo[keynr].seg->charset' failed.
09:44:00 UTC - mysqld got signal 6 ;
Most likely, you have hit a bug, but this error can also be caused by malfunctioning hardware.
Thread pointer: 0x6270000d2100
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 = 7fec8a6f8b20 thread_stack 0x100000
/home/mysql-server/mysql-8.0.29-origin-dev/bin/mysqld(__interceptor_backtrace+0x5b) [0x5e4e34b]
/home/mysql-server/mysql-8.0.29-origin-dev/bin/mysqld(my_print_stacktrace(unsigned char const*, unsigned long)+0x10d) [0xb6ab1cd]
/home/mysql-server/mysql-8.0.29-origin-dev/bin/mysqld(print_fatal_signal(int)+0x389) [0x8149469]
/home/mysql-server/mysql-8.0.29-origin-dev/bin/mysqld(handle_fatal_signal+0x175) [0x8149ab5]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x11390) [0x7fecb6986390]
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0x38) [0x7fecb4e7a438]
/lib/x86_64-linux-gnu/libc.so.6(abort+0x16a) [0x7fecb4e7c03a]
/lib/x86_64-linux-gnu/libc.so.6(+0x2dbe7) [0x7fecb4e72be7]
/lib/x86_64-linux-gnu/libc.so.6(+0x2dc92) [0x7fecb4e72c92]
/home/mysql-server/mysql-8.0.29-origin-dev/bin/mysqld(ft_init_boolean_search+0xc60) [0xd513800]
/home/mysql-server/mysql-8.0.29-origin-dev/bin/mysqld(ft_init_search(unsigned int, void*, unsigned int, unsigned char*, unsigned int, CHARSET_INFO const*, unsigned char*)+0xd9) [0xd512a59]
/home/mysql-server/mysql-8.0.29-origin-dev/bin/mysqld(ha_myisam::ft_init_ext(unsigned int, unsigned int, String*)+0xdc) [0xd50c6fc]
/home/mysql-server/mysql-8.0.29-origin-dev/bin/mysqld(Item_func_match::init_search(THD*)+0xd62) [0x63709d2]
/home/mysql-server/mysql-8.0.29-origin-dev/bin/mysqld(init_ftfuncs(THD*, Query_block*)+0x6cb) [0x736b4ab]
/home/mysql-server/mysql-8.0.29-origin-dev/bin/mysqld(JOIN::optimize_fts_query()+0xc8f) [0x774bd7f]
/home/mysql-server/mysql-8.0.29-origin-dev/bin/mysqld(JOIN::optimize(bool)+0x6aa5) [0x7730575]
/home/mysql-server/mysql-8.0.29-origin-dev/bin/mysqld(Query_block::optimize(THD*, bool)+0x330) [0x7b71280]
/home/mysql-server/mysql-8.0.29-origin-dev/bin/mysqld(Query_expression::optimize(THD*, TABLE*, bool, bool)+0x404) [0x7e176c4]
/home/mysql-server/mysql-8.0.29-origin-dev/bin/mysqld(TABLE_LIST::optimize_derived(THD*)+0x47b) [0x75ce1bb]
/home/mysql-server/mysql-8.0.29-origin-dev/bin/mysqld(JOIN::optimize(bool)+0x141a) [0x772aeea]
/home/mysql-server/mysql-8.0.29-origin-dev/bin/mysqld(Query_block::optimize(THD*, bool)+0x330) [0x7b71280]
/home/mysql-server/mysql-8.0.29-origin-dev/bin/mysqld(Query_expression::optimize(THD*, TABLE*, bool, bool)+0x404) [0x7e176c4]
/home/mysql-server/mysql-8.0.29-origin-dev/bin/mysqld(Sql_cmd_dml::execute_inner(THD*)+0x9a) [0x7b66eba]
/home/mysql-server/mysql-8.0.29-origin-dev/bin/mysqld(Sql_cmd_dml::execute(THD*)+0xe1d) [0x7b6423d]
/home/mysql-server/mysql-8.0.29-origin-dev/bin/mysqld(mysql_execute_command(THD*, bool)+0x3583) [0x794fbc3]
/home/mysql-server/mysql-8.0.29-origin-dev/bin/mysqld(dispatch_sql_command(THD*, Parser_state*)+0x1b5d) [0x7945c8d]
/home/mysql-server/mysql-8.0.29-origin-dev/bin/mysqld(dispatch_command(THD*, COM_DATA const*, enum_server_command)+0x974a) [0x793c61a]
/home/mysql-server/mysql-8.0.29-origin-dev/bin/mysqld(do_command(THD*)+0xf9c) [0x794149c]
/home/mysql-server/mysql-8.0.29-origin-dev/bin/mysqld() [0x80d00a2]
/home/mysql-server/mysql-8.0.29-origin-dev/bin/mysqld() [0xd6ac2da]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x76ba) [0x7fecb697c6ba]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x6d) [0x7fecb4f4c51d]

Trying to get some variables.
Some pointers may be invalid and cause the dump to abort.
Query (6190042c53f4): SELECT INTERVAL( 123 , - 16 , 4 , - 46 ) AS ca9 FROM ( SELECT ra3 . f1 , ra3 . f3 IN ( SELECT DISTINCTROW 3 AS ca0 FROM t1 ra5 ) IS TRUE AS ca1 , ra2 . f3 IS NOT NULL AS ca2 , ra3 . f2 IS TRUE AS ca3 , 'N' IS NOT TRUE AS ca4 , MATCH ( ra1 . f1 ) AGAINST ( 'w' IN BOOLEAN MODE ) AND ra4 . f5 = 123 AS ca5 , - 2147483647 IS NOT FALSE AS ca6 , CASE WHEN 1 < 123 THEN 'ZJ' ELSE 'ZJ' END ca7 , ra1 . f3 IS NOT UNKNOWN AS ca8 FROM t1 ra4 STRAIGHT_JOIN ( t1 ra1 JOIN t1 ra2 ON ra1 . f5 = ra1 . f3 JOIN t1 ra3 ON ra3 . f4 = ra1 . f1 ) ON ra4 . f4 = ra2 . f2 ) AS ra0 WHERE ra0 . f1 >= ra0 . ca3 AND ra0 . ca4 <= ra0 . ca5
Connection ID (thread ID): 30506
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 affected.

How to repeat:
Test case:

```
CREATE TABLE t1 ( pk INT PRIMARY KEY , f1 INT , f2 INT , f3 VARCHAR ( 10 ) , f4 VARCHAR ( 10 ) , f5 VARCHAR ( 64 ) , KEY ( f1 ) , KEY ( f4 ) , KEY ( f5 ) ) ENGINE = MyISAM ;
INSERT INTO t1 VALUES ( 2 , 345 , 123 , 'h' , 'M' , 'w' ) , ( 3 , 46 , 61235 , 'N' , 'w' , 'r' ) , ( 4 , 69 , 0 , 'why' , 'Washington' , 'itis' ) ;
SELECT INTERVAL( 123 , - 16 , 4 , - 46 ) AS ca9 FROM ( SELECT ra3 . f1 , ra3 . f3 IN ( SELECT DISTINCTROW 3 AS ca0 FROM t1 ra5 ) IS TRUE AS ca1 , ra2 . f3 IS NOT NULL AS ca2 , ra3 . f2 IS TRUE AS ca3 , 'N' IS NOT TRUE AS ca4 , MATCH ( ra1 . f1 ) AGAINST ( 'w' IN BOOLEAN MODE ) AND ra4 . f5 = 123 AS ca5 , - 2147483647 IS NOT FALSE AS ca6 , CASE WHEN 1 < 123 THEN 'ZJ' ELSE 'ZJ' END ca7 , ra1 . f3 IS NOT UNKNOWN AS ca8 FROM t1 ra4 STRAIGHT_JOIN ( t1 ra1 JOIN t1 ra2 ON ra1 . f5 = ra1 . f3 JOIN t1 ra3 ON ra3 . f4 = ra1 . f1 ) ON ra4 . f4 = ra2 . f2 ) AS ra0 WHERE ra0 . f1 >= ra0 . ca3 AND ra0 . ca4 <= ra0 . ca5 ;
```
[4 Jul 6:13] MySQL Verification Team
Hello Wang Ke,

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

regards,
Umesh