Bug #74646 Assertion `((Item_result_field*)item)->result_field' failed in create_tmp_field

Submitted: 31 Oct 2014 9:51 Modified: 31 Oct 2014 10:14
Reporter: Ramesh Sivaraman Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: DML Severity:S3 (Non-critical)
Version:5.6.20-debug, 5.6.22, 5.7.6 OS:Linux (CentOS 7)
Assigned to: CPU Architecture:Any

[31 Oct 2014 9:51] Ramesh Sivaraman
Description:
mysqld: /ssd/ramesh/mysql-server/mysql-5.6/sql/sql_tmp_table.cc:363: Field* create_tmp_field(THD*, TABLE*, Item*, Item::Type, Item***, Field**, Field**, bool, bool, bool, bool): Assertion `((Item_result_field*)item)->result_field' failed.
09:47:56 UTC - mysqld got signal 6 ;

***** GDB info

#0  0x00007f74137cd771 in pthread_kill () from /lib64/libpthread.so.0
#1  0x0000000000a9035e in my_write_core (sig=6) at /ssd/ramesh/mysql-server/mysql-5.6/mysys/stacktrace.c:422
#2  0x0000000000723688 in handle_fatal_signal (sig=6) at /ssd/ramesh/mysql-server/mysql-5.6/sql/signal_handler.cc:230
#3  <signal handler called>
#4  0x00007f74125d95c9 in raise () from /lib64/libc.so.6
#5  0x00007f74125dacd8 in abort () from /lib64/libc.so.6
#6  0x00007f74125d2536 in __assert_fail_base () from /lib64/libc.so.6
#7  0x00007f74125d25e2 in __assert_fail () from /lib64/libc.so.6
#8  0x000000000084bdc1 in create_tmp_field (thd=0x7f7380324000, table=0x7f73771ce010, item=0x7f73771cabb0, type=Item::REF_ITEM, copy_func=0x7f7413dc31e8, from_field=0x7f73771cec20, default_field=0x7f73771cec10, group=false, modify_item=false, table_cant_handle_bit_fields=false, make_copy_field=true) at /ssd/ramesh/mysql-server/mysql-5.6/sql/sql_tmp_table.cc:363
#9  0x000000000084d02e in create_tmp_table (thd=0x7f7380324000, param=0x7f73771ccdb8, fields=..., group=0x0, distinct=true, save_sum_fields=false, select_options=2147748608, rows_limit=18446744073709551615, table_alias=0xed33b7 "") at /ssd/ramesh/mysql-server/mysql-5.6/sql/sql_tmp_table.cc:729
#10 0x00000000006ded90 in Aggregator_distinct::setup (this=0x7f73771cc840, thd=0x7f7380324000) at /ssd/ramesh/mysql-server/mysql-5.6/sql/item_sum.cc:848
#11 0x00000000007a86ca in Item_sum::aggregator_setup (this=0x7f73771cc558, thd=0x7f7380324000) at /ssd/ramesh/mysql-server/mysql-5.6/sql/item_sum.h:488
#12 0x000000000079eeb2 in setup_sum_funcs (thd=0x7f7380324000, func_ptr=0x7f73771caef0) at /ssd/ramesh/mysql-server/mysql-5.6/sql/sql_executor.cc:464
#13 0x0000000000807fe5 in JOIN::make_tmp_tables_info (this=0x7f73771ca3a8) at /ssd/ramesh/mysql-server/mysql-5.6/sql/sql_select.cc:5242
#14 0x00000000009a1a7d in JOIN::optimize (this=0x7f73771ca3a8) at /ssd/ramesh/mysql-server/mysql-5.6/sql/sql_optimizer.cc:1013
#15 0x00000000007fe0ee in mysql_execute_select (thd=0x7f7380324000, select_lex=0x7f7380326878, free_join=true) at /ssd/ramesh/mysql-server/mysql-5.6/sql/sql_select.cc:1086
#16 0x00000000007fe43f in mysql_select (thd=0x7f7380324000, tables=0x7f737701f8e8, wild_num=0, fields=..., conds=0x0, order=0x7f7380326a40, group=0x7f7380326978, having=0x0, select_options=2147748608, result=0x7f7377020fe0, unit=0x7f7380326230, select_lex=0x7f7380326878) at /ssd/ramesh/mysql-server/mysql-5.6/sql/sql_select.cc:1221
#17 0x00000000007fc4c7 in handle_select (thd=0x7f7380324000, result=0x7f7377020fe0, setup_tables_done_option=0) at /ssd/ramesh/mysql-server/mysql-5.6/sql/sql_select.cc:110
#18 0x00000000007d681b in execute_sqlcom_select (thd=0x7f7380324000, all_tables=0x7f737701f8e8) at /ssd/ramesh/mysql-server/mysql-5.6/sql/sql_parse.cc:5103
#19 0x00000000007cf5cb in mysql_execute_command (thd=0x7f7380324000) at /ssd/ramesh/mysql-server/mysql-5.6/sql/sql_parse.cc:2649
#20 0x00000000007d8fa4 in mysql_parse (thd=0x7f7380324000, rawbuf=0x7f737701f010 "SELECT SUM(b),COUNT(DISTINCT b),COUNT(*) FROM t1 GROUP BY a WITH ROLLUP", length=71, parser_state=0x7f7413dc4e70) at /ssd/ramesh/mysql-server/mysql-5.6/sql/sql_parse.cc:6245
#21 0x00000000007cc557 in dispatch_command (command=COM_QUERY, thd=0x7f7380324000, packet=0x7f7380362001 "SELECT SUM(b),COUNT(DISTINCT b),COUNT(*) FROM t1 GROUP BY a WITH ROLLUP", packet_length=71) at /ssd/ramesh/mysql-server/mysql-5.6/sql/sql_parse.cc:1332
#22 0x00000000007cb646 in do_command (thd=0x7f7380324000) at /ssd/ramesh/mysql-server/mysql-5.6/sql/sql_parse.cc:1034
#23 0x0000000000793a61 in do_handle_one_connection (thd_arg=0x7f7380324000) at /ssd/ramesh/mysql-server/mysql-5.6/sql/sql_connect.cc:982
#24 0x000000000079354a in handle_one_connection (arg=0x7f7380324000) at /ssd/ramesh/mysql-server/mysql-5.6/sql/sql_connect.cc:898
#25 0x0000000000ad4b5c in pfs_spawn_thread (arg=0x7f740fbfeb00) at /ssd/ramesh/mysql-server/mysql-5.6/storage/perfschema/pfs.cc:1860
#26 0x00007f74137c8df3 in start_thread () from /lib64/libpthread.so.0
#27 0x00007f741269a01d in clone () from /lib64/libc.so.6

How to repeat:
DROP DATABASE test;CREATE DATABASE test;USE test;
create TEMPORARY TABLE t2(a int)engine=heap;
CREATE TABLE t2(a int KEY,b CHAR (1)) ENGINE=InnoDB PARTITION BY HASH (a) PARTITIONS 13;
DROP TABLE t2;
create view t1 as select a,6*a as b,7*a as c from t2;
SELECT SUM(b),COUNT(DISTINCT b),COUNT(*) FROM t1 GROUP BY a WITH ROLLUP;
[31 Oct 2014 10:14] MySQL Verification Team
Hello Ramesh Sivaraman,

Thank you for the bug report and test case.
Confirmed that 5.6.22 debug build asserts.

Thanks,
Umes
[31 Oct 2014 10:16] MySQL Verification Team
// 5.6.22 Only debug build affected

mysql> show variables like '%version%';
+-------------------------+---------------------------------------------------------+
| Variable_name           | Value                                                   |
+-------------------------+---------------------------------------------------------+
| innodb_version          | 5.6.22                                                  |
| protocol_version        | 10                                                      |
| slave_type_conversions  |                                                         |
| version                 | 5.6.22-enterprise-commercial-advanced                   |
| version_comment         | MySQL Enterprise Server - Advanced Edition (Commercial) |
| version_compile_machine | x86_64                                                  |
| version_compile_os      | Linux                                                   |
+-------------------------+---------------------------------------------------------+
7 rows in set (0.00 sec)

mysql> DROP DATABASE test;CREATE DATABASE test;USE test;
Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.00 sec)

Database changed
mysql> create TEMPORARY TABLE t2(a int)engine=heap;
Query OK, 0 rows affected (0.00 sec)

mysql> CREATE TABLE t2(a int KEY,b CHAR (1)) ENGINE=InnoDB PARTITION BY HASH (a) PARTITIONS 13;
DROP TABLE t2;
create view t1 as select a,6*a as b,7*a as c from t2;
SELECT SUM(b),COUNT(DISTINCT b),COUNT(*) FROM t1 GROUP BY a WITH ROLLUP;Query OK, 0 rows affected (0.24 sec)

mysql> DROP TABLE t2;
Query OK, 0 rows affected (0.00 sec)

mysql> create view t1 as select a,6*a as b,7*a as c from t2;
Query OK, 0 rows affected (0.00 sec)

mysql> SELECT SUM(b),COUNT(DISTINCT b),COUNT(*) FROM t1 GROUP BY a WITH ROLLUP;
Empty set (0.00 sec)

// debug build

mysql> DROP DATABASE test;CREATE DATABASE test;USE test;
Query OK, 0 rows affected (0.01 sec)

Query OK, 1 row affected (0.00 sec)

Database changed
mysql> create TEMPORARY TABLE t2(a int)engine=heap;
Query OK, 0 rows affected (0.00 sec)

mysql> CREATE TABLE t2(a int KEY,b CHAR (1)) ENGINE=InnoDB PARTITION BY HASH (a) PARTITIONS 13;
DROP TABLE t2;
create view t1 as select a,6*a as b,7*a as c from t2;
SELECT SUM(b),COUNT(DISTINCT b),COUNT(*) FROM t1 GROUP BY a WITH ROLLUP;Query OK, 0 rows affected (0.31 sec)

mysql> DROP TABLE t2;
Query OK, 0 rows affected (0.00 sec)

mysql> create view t1 as select a,6*a as b,7*a as c from t2;
Query OK, 0 rows affected (0.01 sec)

mysql> SELECT SUM(b),COUNT(DISTINCT b),COUNT(*) FROM t1 GROUP BY a WITH ROLLUP;
ERROR 2013 (HY000): Lost connection to MySQL server during query

// 5.6.22 - debug

(gdb) bt
#0  0x00007f6e8a27b8ac in pthread_kill () from /lib64/libpthread.so.0
#1  0x0000000000b0011b in my_write_core (sig=6) at /pb2/build/sb_0-13562263-1414689457.82/mysqlcom-pro-5.6.22/mysys/stacktrace.c:422
#2  0x000000000077ecb8 in handle_fatal_signal (sig=6) at /pb2/build/sb_0-13562263-1414689457.82/mysqlcom-pro-5.6.22/sql/signal_handler.cc:230
#3  <signal handler called>
#4  0x00007f6e89646625 in raise () from /lib64/libc.so.6
#5  0x00007f6e89647e05 in abort () from /lib64/libc.so.6
#6  0x00007f6e8963f74e in __assert_fail_base () from /lib64/libc.so.6
#7  0x00007f6e8963f810 in __assert_fail () from /lib64/libc.so.6
#8  0x00000000008ad077 in create_tmp_field (thd=0x3835a00, table=0x7f6e3808eda0, item=0x7f6e3807b580, type=Item::REF_ITEM, copy_func=0x7f6e61abf488, from_field=0x7f6e3808f9b0,
    default_field=0x7f6e3808f9a0, group=false, modify_item=false, table_cant_handle_bit_fields=false, make_copy_field=true)
    at /pb2/build/sb_0-13562263-1414689457.82/mysqlcom-pro-5.6.22/sql/sql_tmp_table.cc:363
#9  0x00000000008ae397 in create_tmp_table (thd=0x3835a00, param=0x7f6e3807d778, fields=..., group=0x0, distinct=true, save_sum_fields=false, select_options=2147748608,
    rows_limit=18446744073709551615, table_alias=0xfff65f "") at /pb2/build/sb_0-13562263-1414689457.82/mysqlcom-pro-5.6.22/sql/sql_tmp_table.cc:729
#10 0x00000000007391ab in Aggregator_distinct::setup (this=0x7f6e3807d200, thd=0x3835a00) at /pb2/build/sb_0-13562263-1414689457.82/mysqlcom-pro-5.6.22/sql/item_sum.cc:845
#11 0x00000000008062fa in Item_sum::aggregator_setup (this=0x7f6e3807cf18, thd=0x3835a00) at /pb2/build/sb_0-13562263-1414689457.82/mysqlcom-pro-5.6.22/sql/item_sum.h:488
#12 0x00000000007fc72e in setup_sum_funcs (thd=0x3835a00, func_ptr=0x7f6e3807b8c0) at /pb2/build/sb_0-13562263-1414689457.82/mysqlcom-pro-5.6.22/sql/sql_executor.cc:464
#13 0x0000000000867c0d in JOIN::make_tmp_tables_info (this=0x7f6e3807ad78) at /pb2/build/sb_0-13562263-1414689457.82/mysqlcom-pro-5.6.22/sql/sql_select.cc:5242
#14 0x0000000000a0b560 in JOIN::optimize (this=0x7f6e3807ad78) at /pb2/build/sb_0-13562263-1414689457.82/mysqlcom-pro-5.6.22/sql/sql_optimizer.cc:1013
#15 0x000000000085d81b in mysql_execute_select (thd=0x3835a00, select_lex=0x3838278, free_join=true) at /pb2/build/sb_0-13562263-1414689457.82/mysqlcom-pro-5.6.22/sql/sql_select.cc:1086
#16 0x000000000085db83 in mysql_select (thd=0x3835a00, tables=0x7f6e380058c8, wild_num=0, fields=..., conds=0x0, order=0x3838440, group=0x3838378, having=0x0, select_options=2147748608,
    result=0x7f6e38006fc0, unit=0x3837c30, select_lex=0x3838278) at /pb2/build/sb_0-13562263-1414689457.82/mysqlcom-pro-5.6.22/sql/sql_select.cc:1221
#17 0x000000000085bb8f in handle_select (thd=0x3835a00, result=0x7f6e38006fc0, setup_tables_done_option=0) at /pb2/build/sb_0-13562263-1414689457.82/mysqlcom-pro-5.6.22/sql/sql_select.cc:110
#18 0x00000000008354bc in execute_sqlcom_select (thd=0x3835a00, all_tables=0x7f6e380058c8) at /pb2/build/sb_0-13562263-1414689457.82/mysqlcom-pro-5.6.22/sql/sql_parse.cc:5103
#19 0x000000000082dc14 in mysql_execute_command (thd=0x3835a00) at /pb2/build/sb_0-13562263-1414689457.82/mysqlcom-pro-5.6.22/sql/sql_parse.cc:2649
#20 0x00000000008380e1 in mysql_parse (thd=0x3835a00, rawbuf=0x7f6e38004ff0 "SELECT SUM(b),COUNT(DISTINCT b),COUNT(*) FROM t1 GROUP BY a WITH ROLLUP", length=71, parser_state=0x7f6e61ac1680)
    at /pb2/build/sb_0-13562263-1414689457.82/mysqlcom-pro-5.6.22/sql/sql_parse.cc:6357
#21 0x000000000082aa63 in dispatch_command (command=COM_QUERY, thd=0x3835a00, packet=0x3965351 "SELECT SUM(b),COUNT(DISTINCT b),COUNT(*) FROM t1 GROUP BY a WITH ROLLUP", packet_length=71)
    at /pb2/build/sb_0-13562263-1414689457.82/mysqlcom-pro-5.6.22/sql/sql_parse.cc:1332
#22 0x0000000000829ac8 in do_command (thd=0x3835a00) at /pb2/build/sb_0-13562263-1414689457.82/mysqlcom-pro-5.6.22/sql/sql_parse.cc:1034
#23 0x00000000007f0f17 in do_handle_one_connection (thd_arg=0x3835a00) at /pb2/build/sb_0-13562263-1414689457.82/mysqlcom-pro-5.6.22/sql/sql_connect.cc:982
#24 0x00000000007f09e8 in handle_one_connection (arg=0x3835a00) at /pb2/build/sb_0-13562263-1414689457.82/mysqlcom-pro-5.6.22/sql/sql_connect.cc:898
#25 0x0000000000e64c25 in pfs_spawn_thread (arg=0x3928a80) at /pb2/build/sb_0-13562263-1414689457.82/mysqlcom-pro-5.6.22/storage/perfschema/pfs.cc:1860
#26 0x00007f6e8a2769d1 in start_thread () from /lib64/libpthread.so.0
#27 0x00007f6e896fc9dd in clone () from /lib64/libc.so.6
[31 Oct 2014 10:27] MySQL Verification Team
// 5.7.6 - only debug build affected

(gdb) bt
#0  0x00007fd01cfb68ac in pthread_kill () from /lib64/libpthread.so.0
#1  0x0000000000f990a1 in my_write_core (sig=6) at /pb2/build/sb_0-13559856-1414670154.69/mysqlcom-pro-5.7.6-m16/mysys/stacktrace.c:247
#2  0x000000000092d7cc in handle_fatal_signal (sig=6) at /pb2/build/sb_0-13559856-1414670154.69/mysqlcom-pro-5.7.6-m16/sql/signal_handler.cc:219
#3  <signal handler called>
#4  0x00007fd01c381625 in raise () from /lib64/libc.so.6
#5  0x00007fd01c382e05 in abort () from /lib64/libc.so.6
#6  0x00007fd01c37a74e in __assert_fail_base () from /lib64/libc.so.6
#7  0x00007fd01c37a810 in __assert_fail () from /lib64/libc.so.6
#8  0x0000000000d42220 in create_tmp_field (thd=0x7fcfcc000d30, table=0x7fcfcc08f6a0, item=0x7fcfcc07ba08, type=Item::REF_ITEM, copy_func=0x7fcfcc0464e0, from_field=0x7fcfcc0903b8,
    default_field=0x7fcfcc090398, group=false, modify_item=false, table_cant_handle_bit_fields=false, make_copy_field=true)
    at /pb2/build/sb_0-13559856-1414670154.69/mysqlcom-pro-5.7.6-m16/sql/sql_tmp_table.cc:365
#9  0x0000000000d4395e in create_tmp_table (thd=0x7fcfcc000d30, param=0x7fcfcc07d660, fields=..., group=0x0, distinct=true, save_sum_fields=false, select_options=2147748608,
    rows_limit=18446744073709551615, table_alias=0x15ab03a "") at /pb2/build/sb_0-13559856-1414670154.69/mysqlcom-pro-5.7.6-m16/sql/sql_tmp_table.cc:839
#10 0x0000000000bb09a1 in Aggregator_distinct::setup (this=0x7fcfcc07cd10, thd=0x7fcfcc000d30) at /pb2/build/sb_0-13559856-1414670154.69/mysqlcom-pro-5.7.6-m16/sql/item_sum.cc:913
#11 0x0000000000c79c6c in Item_sum::aggregator_setup (this=0x7fcfcc07ca48, thd=0x7fcfcc000d30) at /pb2/build/sb_0-13559856-1414670154.69/mysqlcom-pro-5.7.6-m16/sql/item_sum.h:493
#12 0x0000000000c6f7b1 in setup_sum_funcs (thd=0x7fcfcc000d30, func_ptr=0x7fcfcc07bd38) at /pb2/build/sb_0-13559856-1414670154.69/mysqlcom-pro-5.7.6-m16/sql/sql_executor.cc:460
#13 0x0000000000cfc262 in JOIN::make_tmp_tables_info (this=0x7fcfcc07b178) at /pb2/build/sb_0-13559856-1414670154.69/mysqlcom-pro-5.7.6-m16/sql/sql_select.cc:3685
#14 0x0000000000c90c31 in JOIN::optimize (this=0x7fcfcc07b178) at /pb2/build/sb_0-13559856-1414670154.69/mysqlcom-pro-5.7.6-m16/sql/sql_optimizer.cc:614
#15 0x0000000000cf49c2 in mysql_prepare_and_optimize_select (thd=0x7fcfcc000d30, fields=..., select_options=2147748608, result=0x7fcfcc044c18, select_lex=0x7fcfcc005520,
    free_join=0x7fd0084c9d7e) at /pb2/build/sb_0-13559856-1414670154.69/mysqlcom-pro-5.7.6-m16/sql/sql_select.cc:1014
#16 0x0000000000cf4a84 in mysql_select (thd=0x7fcfcc000d30, fields=..., select_options=2147748608, result=0x7fcfcc044c18, select_lex=0x7fcfcc005520)
    at /pb2/build/sb_0-13559856-1414670154.69/mysqlcom-pro-5.7.6-m16/sql/sql_select.cc:1051
#17 0x0000000000cf2f6f in handle_select (thd=0x7fcfcc000d30, result=0x7fcfcc044c18, setup_tables_done_option=0)
    at /pb2/build/sb_0-13559856-1414670154.69/mysqlcom-pro-5.7.6-m16/sql/sql_select.cc:97
#18 0x0000000000cbbfbc in execute_sqlcom_select (thd=0x7fcfcc000d30, all_tables=0x7fcfcc006d00) at /pb2/build/sb_0-13559856-1414670154.69/mysqlcom-pro-5.7.6-m16/sql/sql_parse.cc:4998
#19 0x0000000000cb4078 in mysql_execute_command (thd=0x7fcfcc000d30) at /pb2/build/sb_0-13559856-1414670154.69/mysqlcom-pro-5.7.6-m16/sql/sql_parse.cc:2487
#20 0x0000000000cbce6a in mysql_parse (thd=0x7fcfcc000d30, parser_state=0x7fd0084cb660) at /pb2/build/sb_0-13559856-1414670154.69/mysqlcom-pro-5.7.6-m16/sql/sql_parse.cc:5397
#21 0x0000000000cb0f2c in dispatch_command (command=COM_QUERY, thd=0x7fcfcc000d30, packet=0x7fcfcc009a61 "SELECT SUM(b),COUNT(DISTINCT b),COUNT(*) FROM t1 GROUP BY a WITH ROLLUP",
    packet_length=71) at /pb2/build/sb_0-13559856-1414670154.69/mysqlcom-pro-5.7.6-m16/sql/sql_parse.cc:1249
#22 0x0000000000cafbd4 in do_command (thd=0x7fcfcc000d30) at /pb2/build/sb_0-13559856-1414670154.69/mysqlcom-pro-5.7.6-m16/sql/sql_parse.cc:833
#23 0x0000000000dbe89c in handle_connection (arg=0x48c69a0) at /pb2/build/sb_0-13559856-1414670154.69/mysqlcom-pro-5.7.6-m16/sql/conn_handler/connection_handler_per_thread.cc:298
#24 0x000000000138347f in pfs_spawn_thread (arg=0x471d100) at /pb2/build/sb_0-13559856-1414670154.69/mysqlcom-pro-5.7.6-m16/storage/perfschema/pfs.cc:2137
#25 0x00007fd01cfb19d1 in start_thread () from /lib64/libpthread.so.0
#26 0x00007fd01c4379dd in clone () from /lib64/libc.so.6

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

Page generated in 0.057 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.