[MDEV-15141] Check constraint validation on a datetime field crashes the process Created: 2018-01-31  Updated: 2018-03-14  Resolved: 2018-03-14

Status: Closed
Project: MariaDB Server
Component/s: Temporal Types
Affects Version/s: 10.2.12
Fix Version/s: 10.2.14

Type: Bug Priority: Critical
Reporter: Rond Assignee: Sergei Golubchik
Resolution: Fixed Votes: 0
Labels: None
Environment:

Debian stretch


Issue Links:
Blocks
is blocked by MDEV-11839 move value caching from get_datetime_... Closed
Relates
relates to MDEV-9690 concurrent queries with virtual colum... Closed
Sprint: 10.2.14

 Description   

Process crashes when validating check constraints on datetime values.

Stacktrace:

Thread pointer: 0x7fc96c0009a8
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 = 0x7fc9e0d07cf8 thread_stack 0x30000
/usr/sbin/mysqld(my_print_stacktrace+0x2e)[0x5592eecfebfe]
/usr/sbin/mysqld(handle_fatal_signal+0x41d)[0x5592ee79e14d]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x110c0)[0x7fc9e74ee0c0]
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0xcf)[0x7fc9e5988fcf]
/lib/x86_64-linux-gnu/libc.so.6(abort+0x16a)[0x7fc9e598a3fa]
/usr/lib/x86_64-linux-gnu/libstdc++.so.6(_ZN9__gnu_cxx27__verbose_terminate_handlerEv+0x15d)[0x7fc9e608a0ad]
/usr/lib/x86_64-linux-gnu/libstdc++.so.6(+0x8f066)[0x7fc9e6088066]
/usr/lib/x86_64-linux-gnu/libstdc++.so.6(+0x8f0b1)[0x7fc9e60880b1]
/usr/lib/x86_64-linux-gnu/libstdc++.so.6(+0x8fb8f)[0x7fc9e6088b8f]
/usr/sbin/mysqld(_ZN4Item24get_date_with_conversionEP13st_mysql_timey+0x31)[0x5592ee7b3081]
/usr/sbin/mysqld(_ZN4Item19val_datetime_packedEv+0x1a)[0x5592ee582aca]
/usr/sbin/mysqld(_Z18get_datetime_valueP3THDPPP4ItemS3_16enum_field_typesPb+0x38)[0x5592ee7d14c8]
/usr/sbin/mysqld(_ZN14Arg_comparator16compare_temporalE16enum_field_types+0x55)[0x5592ee7d1715]
/usr/sbin/mysqld(_ZN12Item_func_gt7val_intEv+0x2b)[0x5592ee7c950b]
/usr/sbin/mysqld(_ZN5TABLE18verify_constraintsEb+0x59)[0x5592ee6adcd9]
/usr/sbin/mysqld(_ZN10TABLE_LIST17view_check_optionEP3THDb+0xe8)[0x5592ee6ade48]
/usr/sbin/mysqld(_Z12mysql_insertP3THDP10TABLE_LISTR4ListI4ItemERS3_IS5_ES6_S6_15enum_duplicatesb+0x11d5)[0x5592ee5f0e15]
/usr/sbin/mysqld(_Z21mysql_execute_commandP3THD+0x31d7)[0x5592ee605e47]
/usr/sbin/mysqld(_Z11mysql_parseP3THDPcjP12Parser_statebb+0x28a)[0x5592ee60bb5a]
/usr/sbin/mysqld(_Z16dispatch_command19enum_server_commandP3THDPcjbb+0x215f)[0x5592ee60eb5f]
/usr/sbin/mysqld(_Z10do_commandP3THD+0x167)[0x5592ee60f4b7]
/usr/sbin/mysqld(_Z24do_handle_one_connectionP7CONNECT+0x25a)[0x5592ee6d5f2a]
/usr/sbin/mysqld(handle_one_connection+0x3d)[0x5592ee6d609d]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x7494)[0x7fc9e74e4494]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x3f)[0x7fc9e5a3eaff]

Reproduction:

create database DateConstraintCrash;
use DateConstraintCrash;
create table t1 (id int auto_increment primary key, datecol datetime, check (datecol>'0001-01-01 00:00:00'));
insert into t1 (datecol) values (now());
insert into t1 (datecol) values (now());



 Comments   
Comment by Elena Stepanova [ 2018-02-05 ]

Thanks for the report and testcase, reproducible as described on the current 10.2 and previous 10.2 releases (at least as far as 10.2.6).

10.2 859fe1f24d4 debug

#3  <signal handler called>
#4  0x0000563ecd507c1b in Item::val_temporal_packed (this=0x7f10ac0130e8, f_type=MYSQL_TYPE_DATETIME) at /data/src/10.2/sql/item.h:1412
#5  0x0000563ecd4f4729 in get_datetime_value (thd=0x0, item_arg=0x7f10ac1757a0, cache_arg=0x7f10ac1757f0, f_type=MYSQL_TYPE_DATETIME, is_null=0x7f10bd81720f) at /data/src/10.2/sql/item_cmpfunc.cc:770
#6  0x0000563ecd4f48f0 in Arg_comparator::compare_temporal (this=0x7f10ac175798, type=MYSQL_TYPE_DATETIME) at /data/src/10.2/sql/item_cmpfunc.cc:819
#7  0x0000563ecd170667 in Arg_comparator::compare_datetime (this=0x7f10ac175798) at /data/src/10.2/sql/item_cmpfunc.h:105
#8  0x0000563ecd5084c6 in Arg_comparator::compare (this=0x7f10ac175798) at /data/src/10.2/sql/item_cmpfunc.h:87
#9  0x0000563ecd4f786d in Item_func_gt::val_int (this=0x7f10ac1756d8) at /data/src/10.2/sql/item_cmpfunc.cc:1822
#10 0x0000563ecd34bd91 in TABLE::verify_constraints (this=0x7f10ac00a720, ignore_failure=false) at /data/src/10.2/sql/table.cc:5109
#11 0x0000563ecd34bceb in TABLE_LIST::view_check_option (this=0x7f10ac0125f0, thd=0x7f10ac000b00, ignore_failure=false) at /data/src/10.2/sql/table.cc:5096
#12 0x0000563ecd21fcf8 in mysql_insert (thd=0x7f10ac000b00, table_list=0x7f10ac0125f0, fields=..., values_list=..., update_fields=..., update_values=..., duplic=DUP_ERROR, ignore=false) at /data/src/10.2/sql/sql_insert.cc:1034
#13 0x0000563ecd2474a3 in mysql_execute_command (thd=0x7f10ac000b00) at /data/src/10.2/sql/sql_parse.cc:4418
#14 0x0000563ecd2523c2 in mysql_parse (thd=0x7f10ac000b00, rawbuf=0x7f10ac0124e8 "insert into t1 (datecol) values (now())", length=39, parser_state=0x7f10bd818200, is_com_multi=false, is_next_command=false) at /data/src/10.2/sql/sql_parse.cc:7897
#15 0x0000563ecd240335 in dispatch_command (command=COM_QUERY, thd=0x7f10ac000b00, packet=0x7f10ac170451 "insert into t1 (datecol) values (now())", packet_length=39, is_com_multi=false, is_next_command=false) at /data/src/10.2/sql/sql_parse.cc:1806
#16 0x0000563ecd23ec98 in do_command (thd=0x7f10ac000b00) at /data/src/10.2/sql/sql_parse.cc:1360
#17 0x0000563ecd38cf28 in do_handle_one_connection (connect=0x563ed0594110) at /data/src/10.2/sql/sql_connect.cc:1335
#18 0x0000563ecd38ccb5 in handle_one_connection (arg=0x563ed0594110) at /data/src/10.2/sql/sql_connect.cc:1241
#19 0x0000563ecd7ac47e in pfs_spawn_thread (arg=0x563ed04f3000) at /data/src/10.2/storage/perfschema/pfs.cc:1862
#20 0x00007f10c5213494 in start_thread (arg=0x7f10bd819700) at pthread_create.c:333
#21 0x00007f10c35f993f in clone () from /lib/x86_64-linux-gnu/libc.so.6

10.2 859fe1f24d4 RelWithDebInfo

pure virtual method called
terminate called without an active exception
180205 16:38:09 [ERROR] mysqld got signal 6 ;
 
#4  0x00007f2f4c6523fa in abort () from /lib/x86_64-linux-gnu/libc.so.6
#5  0x00007f2f4cf670ad in __gnu_cxx::__verbose_terminate_handler() () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#6  0x00007f2f4cf65066 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#7  0x00007f2f4cf650b1 in std::terminate() () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#8  0x00007f2f4cf65b8f in __cxa_pure_virtual () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#9  0x000055d7f163841c in Item::get_date_with_conversion (this=0x7f2f3400fcb0, ltime=ltime@entry=0x7f2f46921790, fuzzydate=fuzzydate@entry=33554433) at /data/src/10.2/sql/item.cc:148
#10 0x000055d7f14162c2 in Item::val_datetime_packed (this=<optimized out>) at /data/src/10.2/sql/item.h:1399
#11 0x000055d7f1657cea in val_temporal_packed (f_type=MYSQL_TYPE_DATETIME, this=0x7f2f3400fcb0) at /data/src/10.2/sql/item.h:1412
#12 get_datetime_value (thd=thd@entry=0x0, item_arg=item_arg@entry=0x7f2f3402aa98, cache_arg=cache_arg@entry=0x7f2f3402aae8, f_type=f_type@entry=MYSQL_TYPE_DATETIME, is_null=is_null@entry=0x7f2f4692182f) at /data/src/10.2/sql/item_cmpfunc.cc:770
#13 0x000055d7f1657f50 in Arg_comparator::compare_temporal (this=0x7f2f3402aa90, type=MYSQL_TYPE_DATETIME) at /data/src/10.2/sql/item_cmpfunc.cc:819
#14 0x000055d7f1651a6b in compare (this=<optimized out>) at /data/src/10.2/sql/item_cmpfunc.h:87
#15 Item_func_gt::val_int (this=<optimized out>) at /data/src/10.2/sql/item_cmpfunc.cc:1822
#16 0x000055d7f153eba1 in TABLE::verify_constraints (this=0x7f2f34089dd8, ignore_failure=ignore_failure@entry=false) at /data/src/10.2/sql/table.cc:5109
#17 0x000055d7f153ecf8 in TABLE_LIST::view_check_option (this=this@entry=0x7f2f3400f1b8, thd=thd@entry=0x7f2f340009a8, ignore_failure=<optimized out>) at /data/src/10.2/sql/table.cc:5096
#18 0x000055d7f147f52d in mysql_insert (thd=0x7f2f340009a8, table_list=<optimized out>, fields=..., values_list=..., update_fields=..., update_values=..., duplic=DUP_ERROR, ignore=false) at /data/src/10.2/sql/sql_insert.cc:1034
#19 0x000055d7f1496348 in mysql_execute_command (thd=0x7f2f340009a8) at /data/src/10.2/sql/sql_parse.cc:4418
#20 0x000055d7f149a789 in mysql_parse (thd=0x7f2f340009a8, rawbuf=<optimized out>, length=39, parser_state=0x7f2f46923240, is_com_multi=<optimized out>, is_next_command=<optimized out>) at /data/src/10.2/sql/sql_parse.cc:7897
#21 0x000055d7f149d1e4 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x7f2f340009a8, packet=packet@entry=0x7f2f34006d09 "insert into t1 (datecol) values (now())", packet_length=packet_length@entry=39, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /data/src/10.2/sql/sql_parse.cc:1806
#22 0x000055d7f149da83 in do_command (thd=0x7f2f340009a8) at /data/src/10.2/sql/sql_parse.cc:1360
#23 0x000055d7f1565494 in do_handle_one_connection (connect=connect@entry=0x55d7f3a00048) at /data/src/10.2/sql/sql_connect.cc:1335
#24 0x000055d7f1565634 in handle_one_connection (arg=arg@entry=0x55d7f3a00048) at /data/src/10.2/sql/sql_connect.cc:1241
#25 0x000055d7f1826444 in pfs_spawn_thread (arg=0x55d7f39b55c8) at /data/src/10.2/storage/perfschema/pfs.cc:1862
#26 0x00007f2f4e320494 in start_thread (arg=0x7f2f46924700) at pthread_create.c:333
#27 0x00007f2f4c70693f in clone () from /lib/x86_64-linux-gnu/libc.so.6

Comment by Alexander Barkov [ 2018-03-14 ]

OK to push.

Generated at Thu Feb 08 08:18:59 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.