Bug #97340 Assertion "!check_datetime_range.my_time"
Submitted: 23 Oct 2019 8:12 Modified: 25 Feb 19:21
Reporter: Hrvoje Matijakovic Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: DML Severity:S6 (Debug Builds)
Version:8.0.18, 5.7.28 OS:CentOS
Assigned to: Martin Hansson CPU Architecture:x86

[23 Oct 2019 8:12] Hrvoje Matijakovic
Description:
Following query results in a crash on the debug build. I couldn't reproduce it on the release build.

gdb from the debug build:

Core was generated by `/sdc/MS151019-mysql-8.0.18-linux-x86_64-debug/bin/mysqld --no-defaults --basedi'.
Program terminated with signal 6, Aborted.
#0  0x00007fb27ac55a61 in __pthread_kill (threadid=<optimized out>, signo=6) at ../nptl/sysdeps/unix/sysv/linux/pthread_kill.c:59
59        val = INTERNAL_SYSCALL (tgkill, err, 3, THREAD_GETMEM (THREAD_SELF, pid),
(gdb) bt
+bt
#0  0x00007fb27ac55a61 in __pthread_kill (threadid=<optimized out>, signo=6) at ../nptl/sysdeps/unix/sysv/linux/pthread_kill.c:59
#1  0x00000000048f003d in my_write_core (sig=6) at /sdc/MS-8.0.18_dbg/mysys/stacktrace.cc:305
#2  0x00000000035e030e in handle_fatal_signal (sig=6) at /sdc/MS-8.0.18_dbg/sql/signal_handler.cc:169
#3  <signal handler called>
#4  0x00007fb278a9d337 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:55
#5  0x00007fb278a9ea28 in __GI_abort () at abort.c:90
#6  0x00007fb278a96156 in __assert_fail_base (fmt=0x7fb278bf1be0 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x6d30d10 "!check_datetime_range(my_time)", file=file@entry=0x6d30b08 "/sdc/MS-8.0.18_dbg/mysys/my_time.cc", line=line@entry=1808, function=function@entry=0x6d312a0 <TIME_to_longlong_datetime_packed(MYSQL_TIME const&)::__PRETTY_FUNCTION__> "longlong TIME_to_longlong_datetime_packed(const MYSQL_TIME&)") at assert.c:92
#7  0x00007fb278a96202 in __GI___assert_fail (assertion=0x6d30d10 "!check_datetime_range(my_time)", file=0x6d30b08 "/sdc/MS-8.0.18_dbg/mysys/my_time.cc", line=1808, function=0x6d312a0 <TIME_to_longlong_datetime_packed(MYSQL_TIME const&)::__PRETTY_FUNCTION__> "longlong TIME_to_longlong_datetime_packed(const MYSQL_TIME&)") at assert.c:101
#8  0x0000000005381250 in TIME_to_longlong_datetime_packed (my_time=...) at /sdc/MS-8.0.18_dbg/mysys/my_time.cc:1808
#9  0x0000000003745bac in Field_datetimef::store_internal (this=0x7fb21f4a4f50, ltime=0x7fb2623faef0) at /sdc/MS-8.0.18_dbg/sql/field.cc:6071
#10 0x0000000003741f07 in Field_temporal_with_date::store_internal_adjust_frac (this=0x7fb21f4a4f50, ltime=0x7fb2623faef0, warnings=0x7fb2623fac9c) at /sdc/MS-8.0.18_dbg/sql/field.cc:4959
#11 0x0000000003741ba3 in Field_temporal_with_date::store_time (this=0x7fb21f4a4f50, ltime=0x7fb2623faef0, dec_arg=0 '\000') at /sdc/MS-8.0.18_dbg/sql/field.cc:4905                                                                                                                                                          #12 0x00000000037d7345 in Item::save_date_in_field (this=0x7fb21f46e8b0, field=0x7fb21f4a4f50) at /sdc/MS-8.0.18_dbg/sql/item.cc:480
#13 0x0000000003909df6 in Item_date_func::save_in_field_inner (this=0x7fb21f46e8b0, field=0x7fb21f4a4f50) at /sdc/MS-8.0.18_dbg/sql/item_timefunc.h:617
#14 0x00000000037e8ec9 in Item::save_in_field (this=0x7fb21f46e8b0, field=0x7fb21f4a4f50, no_conversions=false) at /sdc/MS-8.0.18_dbg/sql/item.cc:5920
#15 0x000000000333b3ca in fill_record (thd=0x7fb21f420000, table=0x7fb21f443820, ptr=0x7fb21f4a4f48, values=..., bitmap=0x7fb21f4c2528, insert_into_fields_bitmap=0x0, raise_autoinc_has_expl_non_null_val=false) at /sdc/MS-8.0.18_dbg/sql/sql_base.cc:9492
#16 0x00000000039cd7a5 in partition_info::set_used_partition (this=0x7fb21f4c2478, fields=..., values=..., info=..., copy_default_values=false, used_partitions=0x7fb2623fb180) at /sdc/MS-8.0.18_dbg/sql/partition_info.cc:493
#17 0x0000000003a4396e in Sql_cmd_insert_base::prepare_inner (this=0x7fb21f46e998, thd=0x7fb21f420000) at /sdc/MS-8.0.18_dbg/sql/sql_insert.cc:1422
#18 0x0000000003475393 in Sql_cmd_dml::prepare (this=0x7fb21f46e998, thd=0x7fb21f420000) at /sdc/MS-8.0.18_dbg/sql/sql_select.cc:463
#19 0x0000000003475bdb in Sql_cmd_dml::execute (this=0x7fb21f46e998, thd=0x7fb21f420000) at /sdc/MS-8.0.18_dbg/sql/sql_select.cc:644
#20 0x000000000340fca5 in mysql_execute_command (thd=0x7fb21f420000, first_level=true) at /sdc/MS-8.0.18_dbg/sql/sql_parse.cc:3450
#21 0x0000000003415bb6 in mysql_parse (thd=0x7fb21f420000, parser_state=0x7fb2623fcae0) at /sdc/MS-8.0.18_dbg/sql/sql_parse.cc:5257
#22 0x000000000340b046 in dispatch_command (thd=0x7fb21f420000, com_data=0x7fb2623fdb90, command=COM_QUERY) at /sdc/MS-8.0.18_dbg/sql/sql_parse.cc:1765
#23 0x000000000340958b in do_command (thd=0x7fb21f420000) at /sdc/MS-8.0.18_dbg/sql/sql_parse.cc:1273
#24 0x00000000035caf99 in handle_connection (arg=0x7fb22a47a3e0) at /sdc/MS-8.0.18_dbg/sql/conn_handler/connection_handler_per_thread.cc:302
#25 0x00000000050ac3c0 in pfs_spawn_thread (arg=0x7fb276c6a6e0) at /sdc/MS-8.0.18_dbg/storage/perfschema/pfs.cc:2854
#26 0x00007fb27ac50e65 in start_thread (arg=0x7fb2623fe700) at pthread_create.c:307
#27 0x00007fb278b6588d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111
(gdb) quit

How to repeat:
# mysqld options required for replay:  --sql_mode=
CREATE DATABASE test;
USE test;
CREATE TABLE t1(a DATETIME)PARTITION BY HASH (EXTRACT(HOUR_MICROSECOND FROM a));
insert t1 values(addtime(0,0)),(from_days(3652499));
[23 Oct 2019 9:00] Umesh Shastry
Hello Hrvoje Matijakovic,

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

regards,
Umesh
[25 Feb 19:21] Paul Dubois
Posted by developer:
 
Fixed in 8.0.21.

The FROM_DAYS() function could produce results that were out of range
(with the year > 9999).