Bug #111983 Assertion failed in field.cc:4963: virtual longlong Field_temporal_with_date_and
Submitted: 7 Aug 2023 3:10 Modified: 7 Aug 2023 8:53
Reporter: QI XIAODONG Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Optimizer Severity:S6 (Debug Builds)
Version:8.1.0, 8.0.34 OS:Ubuntu
Assigned to: CPU Architecture:Any

[7 Aug 2023 3:10] QI XIAODONG
Description:
2023-08-07T03:07:31.670312Z 0 [System] [MY-015015] [Server] MySQL Server - start.
2023-08-07T03:07:31.912806Z 0 [System] [MY-010116] [Server] /opt/mysql/bin/mysqld (mysqld 8.1.0-debug) starting as process 195487
2023-08-07T03:07:31.926528Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-08-07T03:07:32.385632Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2023-08-07T03:07:33.514596Z 0 [System] [MY-010229] [Server] Starting XA crash recovery...
2023-08-07T03:07:33.524459Z 0 [System] [MY-010232] [Server] XA crash recovery finished.
2023-08-07T03:07:33.637778Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2023-08-07T03:07:33.637829Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2023-08-07T03:07:33.805961Z 0 [System] [MY-010931] [Server] /opt/mysql/bin/mysqld: ready for connections. Version: '8.1.0-debug'  socket: ''  port: 13306  Source distribution.
mysqld: /home/kosaka/Projects/mysql-8.1.0/sql/field.cc:4963: virtual longlong Field_temporal_with_date_and_timef::val_int() const: Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index()))' failed.
2023-08-07T03:07:45Z UTC - mysqld got signal 6 ;
Most likely, you have hit a bug, but this error can also be caused by malfunctioning hardware.
BuildID[sha1]=99b734624d918ef385d652679129f25884b8c39b
Thread pointer: 0x7f3e88fe4d60
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 = 7f3f2c6c5a58 thread_stack 0x100000
/opt/mysql/bin/mysqld(my_print_stacktrace(unsigned char const*, unsigned long)+0x59) [0x55e0e7bb3f48]
/opt/mysql/bin/mysqld(print_fatal_signal(int)+0x3a6) [0x55e0e658dc17]
/opt/mysql/bin/mysqld(handle_fatal_signal+0x79) [0x55e0e658de38]
/lib/x86_64-linux-gnu/libc.so.6(+0x42520) [0x7f3f3b78e520]
/lib/x86_64-linux-gnu/libc.so.6(pthread_kill+0x12c) [0x7f3f3b7e2a7c]
/lib/x86_64-linux-gnu/libc.so.6(raise+0x16) [0x7f3f3b78e476]
/lib/x86_64-linux-gnu/libc.so.6(abort+0xd3) [0x7f3f3b7747f3]
/lib/x86_64-linux-gnu/libc.so.6(+0x2871b) [0x7f3f3b77471b]
/lib/x86_64-linux-gnu/libc.so.6(+0x39e96) [0x7f3f3b785e96]
/opt/mysql/bin/mysqld(Field_temporal_with_date_and_timef::val_int() const+0x94) [0x55e0e670c872]
/opt/mysql/bin/mysqld(Item_field::val_int()+0xa8) [0x55e0e67b3db8]
/opt/mysql/bin/mysqld(Item_func_make_set::val_str(String*)+0x91) [0x55e0e68b8f31]
/opt/mysql/bin/mysqld(Item::evaluate(THD*, String*)+0x14e) [0x55e0e67c4006]
/opt/mysql/bin/mysqld(Item::update_null_value()+0x6d) [0x55e0e67c3e67]
/opt/mysql/bin/mysqld(Item_func::is_null()+0x1c) [0x55e0e61e0466]
/opt/mysql/bin/mysqld(Item_view_ref::is_null()+0x45) [0x55e0e67c84b1]
/opt/mysql/bin/mysqld(Item_func_isnull::resolve_type(THD*)+0x137) [0x55e0e67f3731]
/opt/mysql/bin/mysqld(Item_func::fix_fields(THD*, Item**)+0x1f2) [0x55e0e684c132]
/opt/mysql/bin/mysqld(Item_func_isnull::fix_fields(THD*, Item**)+0x47) [0x55e0e67f3149]
/opt/mysql/bin/mysqld(Item_cond::fix_fields(THD*, Item**)+0x362) [0x55e0e67f1012]
/opt/mysql/bin/mysqld(Item_func::fix_func_arg(THD*, Item**)+0x57) [0x55e0e684c219]
/opt/mysql/bin/mysqld(Item_func::fix_fields(THD*, Item**)+0x1a3) [0x55e0e684c0e3]
/opt/mysql/bin/mysqld(Item_func_case::fix_fields(THD*, Item**)+0x53) [0x55e0e67e9b49]
/opt/mysql/bin/mysqld(setup_fields(THD*, unsigned long, bool, bool, bool, mem_root_deque<Item*> const*, mem_root_deque<Item*>*, Bounds_checked_array<Item*>)+0x4c9) [0x55e0e620221c]
/opt/mysql/bin/mysqld(Query_block::prepare(THD*, mem_root_deque<Item*>*)+0x64b) [0x55e0e63834c1]
/opt/mysql/bin/mysqld(Query_expression::prepare(THD*, Query_result*, mem_root_deque<Item*>*, unsigned long long, unsigned long long)+0x3d5) [0x55e0e6473593]
/opt/mysql/bin/mysqld(Table_ref::resolve_derived(THD*, bool)+0x6d6) [0x55e0e6b0e86a]
/opt/mysql/bin/mysqld(Query_block::resolve_placeholder_tables(THD*, bool)+0x174) [0x55e0e638698a]
/opt/mysql/bin/mysqld(Query_block::prepare(THD*, mem_root_deque<Item*>*)+0x403) [0x55e0e6383279]
/opt/mysql/bin/mysqld(Query_expression::prepare(THD*, Query_result*, mem_root_deque<Item*>*, unsigned long long, unsigned long long)+0x3d5) [0x55e0e6473593]
/opt/mysql/bin/mysqld(Item_subselect::fix_fields(THD*, Item**)+0x11d) [0x55e0e68d1385]
/opt/mysql/bin/mysqld(Item_exists_subselect::fix_fields(THD*, Item**)+0x197) [0x55e0e68d9b9f]
/opt/mysql/bin/mysqld(Item_cond::fix_fields(THD*, Item**)+0x362) [0x55e0e67f1012]
/opt/mysql/bin/mysqld(Query_block::setup_join_cond(THD*, mem_root_deque<Table_ref*>*, bool)+0x229) [0x55e0e63876c5]
/opt/mysql/bin/mysqld(Query_block::setup_join_cond(THD*, mem_root_deque<Table_ref*>*, bool)+0x100) [0x55e0e638759c]
/opt/mysql/bin/mysqld(Query_block::setup_conds(THD*)+0x35d) [0x55e0e63873a1]
/opt/mysql/bin/mysqld(Query_block::prepare(THD*, mem_root_deque<Item*>*)+0x72f) [0x55e0e63835a5]
/opt/mysql/bin/mysqld(Sql_cmd_select::prepare_inner(THD*)+0x245) [0x55e0e63b71fd]
/opt/mysql/bin/mysqld(Sql_cmd_dml::prepare(THD*)+0x497) [0x55e0e63b6c03]
/opt/mysql/bin/mysqld(Sql_cmd_dml::execute(THD*)+0x278) [0x55e0e63b7518]
/opt/mysql/bin/mysqld(mysql_execute_command(THD*, bool)+0x5bdf) [0x55e0e632a1a1]
/opt/mysql/bin/mysqld(dispatch_sql_command(THD*, Parser_state*)+0x7c0) [0x55e0e632c613]
/opt/mysql/bin/mysqld(dispatch_command(THD*, COM_DATA const*, enum_server_command)+0x16e2) [0x55e0e6321a37]
/opt/mysql/bin/mysqld(do_command(THD*)+0x656) [0x55e0e631f8d7]
/opt/mysql/bin/mysqld(+0x390a183) [0x55e0e6577183]
/opt/mysql/bin/mysqld(+0x584a922) [0x55e0e84b7922]
/lib/x86_64-linux-gnu/libc.so.6(+0x94b43) [0x7f3f3b7e0b43]
/lib/x86_64-linux-gnu/libc.so.6(+0x126a00) [0x7f3f3b872a00]

Trying to get some variables.
Some pointers may be invalid and cause the dump to abort.
Query (7f3e89017e20): WITH  jennifer_0 AS (select       subq_0.c0 as c0,      subq_0.c5 as c1   from      (select             ref_0.v0 as c0,            ref_0.v0 as c1,            ref_0.v2 as c2,            ref_0.v2 as c3,            ref_0.v1 as c4,            ref_0.v0 as c5,            ref_0.v1 as c6,            ref_0.v2 as c7         from            test.table0 as ref_0         where ((((EXISTS (                   select                         ref_1.v1 as c0,                        ref_0.v2 as c1,                        ref_0.v1 as c2,                        ref_1.v1 as c3,                        ref_1.v1 as c4,                        ref_0.v1 as c5,                        ref_0.v1 as c6,                        ref_0.v2 as c7,                        ref_0.v0 as c8,                        ref_1.v1 as c9,                        ref_1.v0 as c10,                        ref_0.v2 as c11,                        63 as c12,                        ref_0.v1 as c13,                        ref_0.v2 as c14                     from
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.

How to repeat:
1. Start MySQL Server
2. Start MySQL Client
3. Pipe init.sql(from mysql-bug-data-111890.zip) into client (please ignore execution errors here, as it is machine-generated)
4. Pipe case.sql(attached below) into client 
5. Server crashed with stacktrace
[7 Aug 2023 3:11] QI XIAODONG
case.sql

Attachment: case14.sql (application/octet-stream, text), 33.38 KiB.

[7 Aug 2023 8:53] MySQL Verification Team
Hello QI XIAODONG,

Thank you for the report and test case.
Observed that only debug build is affected.

regards,
Umesh
[7 Aug 2023 8:54] MySQL Verification Team
- 8.0.34 debug build with provided test case

(gdb) bt
#0  0x00007fb39ac27aa1 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  0x00007fb398f72387 in raise () from /lib64/libc.so.6
#5  0x00007fb398f73a78 in abort () from /lib64/libc.so.6
#6  0x00007fb398f6b1a6 in __assert_fail_base () from /lib64/libc.so.6
#7  0x00007fb398f6b252 in __assert_fail () from /lib64/libc.so.6
#8  0x00000000033c1ada in Field_temporal_with_date_and_timef::val_int() const ()
#9  0x0000000003414391 in Item_field::val_int() ()
#10 0x00000000034b4147 in Item_func_make_set::val_str(String*) ()
#11 0x000000000341b384 in Item::evaluate(THD*, String*) ()
#12 0x000000000341b4c2 in Item::update_null_value() ()
#13 0x000000000309dcf3 in Item_func::is_null() ()
#14 0x0000000003416727 in Item_view_ref::is_null() ()
#15 0x0000000003436f7a in Item_func_isnull::resolve_type(THD*) ()
#16 0x000000000347b300 in Item_func::fix_fields(THD*, Item**) ()
#17 0x000000000343ae39 in Item_func_isnull::fix_fields(THD*, Item**) ()
#18 0x00000000034440e0 in Item_cond::fix_fields(THD*, Item**) ()
#19 0x000000000347b10b in Item_func::fix_func_arg(THD*, Item**) ()
#20 0x000000000347b2ee in Item_func::fix_fields(THD*, Item**) ()
#21 0x0000000003432910 in Item_func_case::fix_fields(THD*, Item**) ()
#22 0x00000000030a9f4a in setup_fields(THD*, unsigned long, bool, bool, bool, mem_root_deque<Item*> const*, mem_root_deque<Item*>*, Bounds_checked_array<Item*>) ()
#23 0x00000000031aa0c9 in Query_block::prepare(THD*, mem_root_deque<Item*>*) ()
#24 0x000000000322bc7b in Query_expression::prepare(THD*, Query_result*, mem_root_deque<Item*>*, unsigned long long, unsigned long long) ()
#25 0x0000000003619b29 in Table_ref::resolve_derived(THD*, bool) ()
#26 0x000000000319e256 in Query_block::resolve_placeholder_tables(THD*, bool) ()
#27 0x00000000031a9f3e in Query_block::prepare(THD*, mem_root_deque<Item*>*) ()
#28 0x000000000322bc7b in Query_expression::prepare(THD*, Query_result*, mem_root_deque<Item*>*, unsigned long long, unsigned long long) ()
#29 0x00000000034c6300 in SubqueryWithResult::prepare(THD*) ()
#30 0x00000000034cc86c in Item_subselect::fix_fields(THD*, Item**) ()
#31 0x00000000034440e0 in Item_cond::fix_fields(THD*, Item**) ()
#32 0x00000000031a590a in Query_block::setup_join_cond(THD*, mem_root_deque<Table_ref*>*, bool) [clone .localalias] ()
#33 0x00000000031a5a78 in Query_block::setup_join_cond(THD*, mem_root_deque<Table_ref*>*, bool) [clone .localalias] ()
#34 0x00000000031a5d3c in Query_block::setup_conds(THD*) ()
#35 0x00000000031aa144 in Query_block::prepare(THD*, mem_root_deque<Item*>*) ()
#36 0x00000000031b6a51 in Sql_cmd_select::prepare_inner(THD*) ()
#37 0x00000000031c05c5 in Sql_cmd_dml::prepare(THD*) ()
#38 0x00000000031c08ed in Sql_cmd_dml::execute(THD*) ()
#39 0x0000000003161263 in mysql_execute_command(THD*, bool) ()
#40 0x00000000031626a2 in dispatch_sql_command(THD*, Parser_state*) ()
#41 0x0000000003163cd5 in dispatch_command(THD*, COM_DATA const*, enum_server_command) ()
#42 0x000000000316596c in do_command(THD*) ()
#43 0x00000000032c437c in handle_connection ()
#44 0x00000000047e1af5 in pfs_spawn_thread ()
#45 0x00007fb39ac22ea5 in start_thread () from /lib64/libpthread.so.0
#46 0x00007fb39903ab2d in clone () from /lib64/libc.so.6
(gdb)