Bug #92591 Assertion `uint4korr(kp1) >= 4' failed.
Submitted: 28 Sep 2018 0:40 Modified: 28 Sep 2018 8:16
Reporter: Roel Van de Paar Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server: DML Severity:S1 (Critical)
Version:8.0.12 OS:Any
Assigned to: CPU Architecture:Any

[28 Sep 2018 0:40] Roel Van de Paar
Description:
Core was generated by `/sda/MS300718-mysql-8.0.12-linux-x86_64-debug/bin/mysqld --no-defaults --core-f'.
Program terminated with signal SIGABRT, Aborted.
#0  __pthread_kill (threadid=<optimized out>, signo=6) at ../sysdeps/unix/sysv/linux/pthread_kill.c:57
[Current thread is 1 (Thread 0x7f6833bfe700 (LWP 30531))]
(gdb) bt
#0  __pthread_kill (threadid=<optimized out>, signo=6) at ../sysdeps/unix/sysv/linux/pthread_kill.c:57
#1  0x000055c6bf86878d in my_write_core (sig=6) at /git/MS-8.0.12_dbg/mysys/stacktrace.cc:278
#2  0x000055c6be5bcd94 in handle_fatal_signal (sig=6) at /git/MS-8.0.12_dbg/sql/signal_handler.cc:249
#3  <signal handler called>
#4  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#5  0x00007f6848c65801 in __GI_abort () at abort.c:79
#6  0x00007f6848c5539a in __assert_fail_base (fmt=0x7f6848ddc7d8 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", 
    assertion=assertion@entry=0x55c6c097ae81 "uint4korr(kp1) >= 4", 
    file=file@entry=0x55c6c097ae58 "/git/MS-8.0.12_dbg/sql/cmp_varlen_keys.h", line=line@entry=64, 
    function=function@entry=0x55c6c097cae0 <cmp_varlen_keys(Bounds_checked_array<st_sort_field>, bool, unsigned char const*, unsigned char const*)::__PRETTY_FUNCTION__> "bool cmp_varlen_keys(Bounds_checked_array<st_sort_field>, bool, const uchar*, const uchar*)")
    at assert.c:92
#7  0x00007f6848c55412 in __GI___assert_fail (assertion=0x55c6c097ae81 "uint4korr(kp1) >= 4", 
    file=0x55c6c097ae58 "/git/MS-8.0.12_dbg/sql/cmp_varlen_keys.h", line=64, 
    function=0x55c6c097cae0 <cmp_varlen_keys(Bounds_checked_array<st_sort_field>, bool, unsigned char const*, unsigned char const*)::__PRETTY_FUNCTION__> "bool cmp_varlen_keys(Bounds_checked_array<st_sort_field>, bool, const uchar*, const uchar*)") at assert.c:101
#8  0x000055c6be7283ab in cmp_varlen_keys (sort_field_array=..., use_hash=false, s1=0x7f681aa25669 "", 
    s2=0x7f681aa25660 "\320\f\300\062h\177") at /git/MS-8.0.12_dbg/sql/cmp_varlen_keys.h:64
#9  0x000055c6be71e776 in (anonymous namespace)::Mem_compare_queue_key::operator() (this=0x7f6833bfb6e0, s1=0x7f681aa25669 "", 
    s2=0x7f681aa25660 "\320\f\300\062h\177") at /git/MS-8.0.12_dbg/sql/filesort.cc:121
#10 0x000055c6be72754e in Priority_queue<unsigned char*, std::vector<unsigned char*, Malloc_allocator<unsigned char*> >, (anonymous namespace)::Mem_compare_queue_key>::reverse_heapify (this=0x7f6833bfb6e0, i=1) at /git/MS-8.0.12_dbg/include/priority_queue.h:151
#11 0x000055c6be72718d in Priority_queue<unsigned char*, std::vector<unsigned char*, Malloc_allocator<unsigned char*> >, (anonymous namespace)::Mem_compare_queue_key>::push (this=0x7f6833bfb6e0, x=@0x7f681a859c68: 0x7f681aa25669 "")
    at /git/MS-8.0.12_dbg/include/priority_queue.h:228
#12 0x000055c6be726c66 in Bounded_queue<unsigned char*, unsigned char*, Sort_param, (anonymous namespace)::Mem_compare_queue_key>::push (this=0x7f6833bfb6e0, element=0x7f681a8b3218 "") at /git/MS-8.0.12_dbg/sql/bounded_queue.h:111
#13 0x000055c6be721b29 in read_all_rows (thd=0x7f681a823000, param=0x7f6833bfb7d0, qep_tab=0x7f681a9ae270, fs_info=0x7f681a8466c0, 
    chunk_file=0x7f6833bfb9d0, tempfile=0x7f6833bfb8b0, pq=0x7f6833bfb6e0, found_rows=0x7f6833bfbbc0)
    at /git/MS-8.0.12_dbg/sql/filesort.cc:1011
#14 0x000055c6be71f8b2 in filesort (thd=0x7f681a823000, filesort=0x7f681a9ae6d8, sort_positions=false, 
    examined_rows=0x7f6833bfbbb8, found_rows=0x7f6833bfbbc0, returned_rows=0x7f6833bfbbc8) at /git/MS-8.0.12_dbg/sql/filesort.cc:470
#15 0x000055c6be9b2a06 in create_sort_index (thd=0x7f681a823000, join=0x7f681a9ad818, qep_tab=0x7f681a9ae270)
    at /git/MS-8.0.12_dbg/sql/sql_executor.cc:5395
#16 0x000055c6be9ab71a in QEP_TAB::sort_table (this=0x7f681a9ae270) at /git/MS-8.0.12_dbg/sql/sql_executor.cc:2764
#17 0x000055c6be9aaf6c in join_init_read_record (tab=0x7f681a9ae270) at /git/MS-8.0.12_dbg/sql/sql_executor.cc:2617
#18 0x000055c6be9a7e08 in sub_select (join=0x7f681a9ad818, qep_tab=0x7f681a9ae270, end_of_records=false)
    at /git/MS-8.0.12_dbg/sql/sql_executor.cc:1512
#19 0x000055c6be9a7515 in do_select (join=0x7f681a9ad818) at /git/MS-8.0.12_dbg/sql/sql_executor.cc:1171
#20 0x000055c6be9a4621 in JOIN::exec (this=0x7f681a9ad818) at /git/MS-8.0.12_dbg/sql/sql_executor.cc:294
#21 0x000055c6be471a30 in Sql_cmd_dml::execute_inner (this=0x7f681a9ad648, thd=0x7f681a823000)
    at /git/MS-8.0.12_dbg/sql/sql_select.cc:651
#22 0x000055c6be4714bd in Sql_cmd_dml::execute (this=0x7f681a9ad648, thd=0x7f681a823000) at /git/MS-8.0.12_dbg/sql/sql_select.cc:554
#23 0x000055c6be413a19 in mysql_execute_command (thd=0x7f681a823000, first_level=true) at /git/MS-8.0.12_dbg/sql/sql_parse.cc:4210
#24 0x000055c6be415f94 in mysql_parse (thd=0x7f681a823000, parser_state=0x7f6833bfd330) at /git/MS-8.0.12_dbg/sql/sql_parse.cc:4925
#25 0x000055c6be40baeb in dispatch_command (thd=0x7f681a823000, com_data=0x7f6833bfdc90, command=COM_QUERY)
    at /git/MS-8.0.12_dbg/sql/sql_parse.cc:1607
#26 0x000055c6be40a3c6 in do_command (thd=0x7f681a823000) at /git/MS-8.0.12_dbg/sql/sql_parse.cc:1232
#27 0x000055c6be5aa678 in handle_connection (arg=0x7f68367bb480)
    at /git/MS-8.0.12_dbg/sql/conn_handler/connection_handler_per_thread.cc:308
#28 0x000055c6bff19422 in pfs_spawn_thread (arg=0x7f683c7e7720) at /git/MS-8.0.12_dbg/storage/perfschema/pfs.cc:2836
#29 0x00007f684a6516db in start_thread (arg=0x7f6833bfe700) at pthread_create.c:463
#30 0x00007f6848d4688f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

How to repeat:
# mysqld options required for replay: --sql_mode= 
CREATE DATABASE test;
USE test;
CREATE TABLE t1(c1 VARCHAR(0)NOT NULL);
INSERT INTO t1 VALUES(CURRENT_USER()),(0);
SELECT * FROM t1 ORDER BY c1 LIMIT 2;

Issue may be sporadic at times.
[28 Sep 2018 0:40] Roel Van de Paar
MAY be a duplicate of bug 92448. Test on current source build to be sure.
[28 Sep 2018 8:16] MySQL Verification Team
Not repeatable with current source server either with release or debug build server.
miguel@luz:~/dbs $ 8.0/bin/mysql -uroot -p --socket=/tmp/mysql.sock
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.14 Source distribution BUILD: 2018-SET-27

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> CREATE DATABASE test;
CREATE TABLE t1(c1 VARCHAR(0)NOT NULL);
INSERT INTO t1 VALUES(CURRENT_USER()),(0);
SELECT * FROM t1 ORDER BY c1 LIMIT 2;Query OK, 1 row affected (0,37 sec)

mysql> USE test;
Database changed
mysql> CREATE TABLE t1(c1 VARCHAR(0)NOT NULL);
Query OK, 0 rows affected (1,36 sec)

mysql> INSERT INTO t1 VALUES(CURRENT_USER()),(0);
Query OK, 2 rows affected, 2 warnings (0,29 sec)
Records: 2  Duplicates: 0  Warnings: 2

mysql> SELECT * FROM t1 ORDER BY c1 LIMIT 2;
+----+
| c1 |
+----+
|    |
|    |
+----+
2 rows in set (0,00 sec)

mysql> drop database test;
Query OK, 1 row affected (1,06 sec)

mysql> CREATE DATABASE test;
CREATE TABLE t1(c1 VARCHAR(0)NOT NULL);
INSERT INTO t1 VALUES(CURRENT_USER()),(0);
SELECT * FROM t1 ORDER BY c1 LIMIT 2;Query OK, 1 row affected (0,46 sec)

mysql> USE test;
Database changed
mysql> CREATE TABLE t1(c1 VARCHAR(0)NOT NULL);
Query OK, 0 rows affected (1,68 sec)

mysql> INSERT INTO t1 VALUES(CURRENT_USER()),(0);

Query OK, 2 rows affected, 2 warnings (0,49 sec)
Records: 2  Duplicates: 0  Warnings: 2

mysql> SELECT * FROM t1 ORDER BY c1 LIMIT 2;
+----+
| c1 |
+----+
|    |
|    |
+----+
2 rows in set (0,00 sec)

mysql> drop database test;
Query OK, 1 row affected (0,98 sec)

mysql> CREATE DATABASE test;
CREATE TABLE t1(c1 VARCHAR(0)NOT NULL);
INSERT INTO t1 VALUES(CURRENT_USER()),(0);
SELECT * FROM t1 ORDER BY c1 LIMIT 2;Query OK, 1 row affected (0,36 sec)

mysql> USE test;
Database changed
mysql> CREATE TABLE t1(c1 VARCHAR(0)NOT NULL);
Query OK, 0 rows affected (1,96 sec)

mysql> INSERT INTO t1 VALUES(CURRENT_USER()),(0);
Query OK, 2 rows affected, 2 warnings (0,37 sec)
Records: 2  Duplicates: 0  Warnings: 2

mysql> SELECT * FROM t1 ORDER BY c1 LIMIT 2;
+----+
| c1 |
+----+
|    |
|    |
+----+
2 rows in set (0,00 sec)

mysql>
-------------------------------------------------------------------------------------
miguel@luz:~/dbsd $ 8.0/bin/mysql -uroot -p --socket=/tmp/mysql.sock
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.14-debug Source distribution BUILD: 2018-SET-27

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> CREATE DATABASE test;
CREATE TABLE t1(c1 VARCHAR(0)NOT NULL);
INSERT INTO t1 VALUES(CURRENT_USER()),(0);
SELECT * FROM t1 ORDER BY c1 LIMIT 2;Query OK, 1 row affected (0,41 sec)

mysql> USE test;
Database changed
mysql> CREATE TABLE t1(c1 VARCHAR(0)NOT NULL);
Query OK, 0 rows affected (2,00 sec)

mysql> INSERT INTO t1 VALUES(CURRENT_USER()),(0);
Query OK, 2 rows affected, 2 warnings (0,49 sec)
Records: 2  Duplicates: 0  Warnings: 2

mysql> SELECT * FROM t1 ORDER BY c1 LIMIT 2;
+----+
| c1 |
+----+
|    |
|    |
+----+
2 rows in set (0,00 sec)

mysql> drop database test;
Query OK, 1 row affected (1,40 sec)

mysql> CREATE DATABASE test;
CREATE TABLE t1(c1 VARCHAR(0)NOT NULL);
INSERT INTO t1 VALUES(CURRENT_USER()),(0);
SELECT * FROM t1 ORDER BY c1 LIMIT 2;Query OK, 1 row affected (0,47 sec)

mysql> USE test;
Database changed
mysql> CREATE TABLE t1(c1 VARCHAR(0)NOT NULL);
Query OK, 0 rows affected (1,78 sec)

mysql> INSERT INTO t1 VALUES(CURRENT_USER()),(0);
Query OK, 2 rows affected, 2 warnings (0,59 sec)
Records: 2  Duplicates: 0  Warnings: 2

mysql> SELECT * FROM t1 ORDER BY c1 LIMIT 2;
+----+
| c1 |
+----+
|    |
|    |
+----+
2 rows in set (0,01 sec)

mysql> drop database test;
Query OK, 1 row affected (1,54 sec)

mysql> CREATE DATABASE test;
CREATE TABLE t1(c1 VARCHAR(0)NOT NULL);
INSERT INTO t1 VALUES(CURRENT_USER()),(0);
SELECT * FROM t1 ORDER BY c1 LIMIT 2;Query OK, 1 row affected (0,52 sec)

mysql> USE test;
Database changed
mysql> CREATE TABLE t1(c1 VARCHAR(0)NOT NULL);
Query OK, 0 rows affected (1,91 sec)

mysql> INSERT INTO t1 VALUES(CURRENT_USER()),(0);
Query OK, 2 rows affected, 2 warnings (0,46 sec)
Records: 2  Duplicates: 0  Warnings: 2

mysql> SELECT * FROM t1 ORDER BY c1 LIMIT 2;
+----+
| c1 |
+----+
|    |
|    |
+----+
2 rows in set (0,00 sec)

mysql> drop database test;
Query OK, 1 row affected (1,27 sec)

mysql> CREATE DATABASE test;
CREATE TABLE t1(c1 VARCHAR(0)NOT NULL);
INSERT INTO t1 VALUES(CURRENT_USER()),(0);
SELECT * FROM t1 ORDER BY c1 LIMIT 2;Query OK, 1 row affected (0,37 sec)

mysql> USE test;
Database changed
mysql> CREATE TABLE t1(c1 VARCHAR(0)NOT NULL);
Query OK, 0 rows affected (2,24 sec)

mysql> INSERT INTO t1 VALUES(CURRENT_USER()),(0);
Query OK, 2 rows affected, 2 warnings (0,30 sec)
Records: 2  Duplicates: 0  Warnings: 2

mysql> SELECT * FROM t1 ORDER BY c1 LIMIT 2;
+----+
| c1 |
+----+
|    |
|    |
+----+
2 rows in set (0,01 sec)

mysql>