Bug #72503 assert hit in sec_since_epoch when running RQG temporal
Submitted: 1 May 2014 18:54 Modified: 18 Nov 2014 19:30
Reporter: richard prohaska Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Data Types Severity:S2 (Serious)
Version:5.5.37,5.5.40 OS:Linux (centos 6)
Assigned to: CPU Architecture:Any
Tags: debug builds

[1 May 2014 18:54] richard prohaska
Description:
hit this assert

mysqld: /home/prohaska/mysql-5.5.37/sql/tztime.cc:798: my_time_t sec_since_epoch(int, int, int, int, int, int): Assertion `mon > 0 && mon < 13' failed.

with this stack trace

# 2014-05-01T11:45:21 #8  0x000000000069166e in sec_since_epoch (year=2000, mon=0, mday=23, hour=0, min=0, sec=0) at /home/prohaska/mysql-5.5.37/sql/tztime.cc:798
# 2014-05-01T11:45:21 #9  0x00000000006918c7 in TIME_to_gmt_sec (t=0x7f10456d0560, sp=0x36cb4a0, in_dst_time_gap=0x7f10456d051f "") at /home/prohaska/mysql-5.5.37/sql/tztime.cc:936
# 2014-05-01T11:45:21 #10 0x0000000000691c35 in Time_zone_db::TIME_to_gmt_sec (this=0x36cb568, t=0x7f10456d0560, in_dst_time_gap=0x7f10456d051f "") at /home/prohaska/mysql-5.5.37/sql/tztime.cc:1255
# 2014-05-01T11:45:21 #11 0x00000000007cb4a9 in Item_func_convert_tz::get_date (this=0x7f10340b9330, ltime=0x7f10456d0560, fuzzy_date=0) at /home/prohaska/mysql-5.5.37/sql/item_timefunc.cc:2202
# 2014-05-01T11:45:21 #12 0x00000000007cb29e in Item_func_convert_tz::val_int (this=0x7f10340b9330) at /home/prohaska/mysql-5.5.37/sql/item_timefunc.cc:2168
# 2014-05-01T11:45:21 #13 0x00000000007056cb in Item_date_func::val_real (this=0x7f10340b9330) at /home/prohaska/mysql-5.5.37/sql/item_timefunc.h:486
# 2014-05-01T11:45:21 #14 0x0000000000766010 in Item_func_between::val_int (this=0x7f10340b9528) at /home/prohaska/mysql-5.5.37/sql/item_cmpfunc.cc:2435
# 2014-05-01T11:45:21 #15 0x0000000000742f68 in Item::val_bool (this=0x7f10340b9528) at /home/prohaska/mysql-5.5.37/sql/item.cc:200
# 2014-05-01T11:45:21 #16 0x000000000076ca68 in Item_cond_and::val_int (this=0x7f103419acc0) at /home/prohaska/mysql-5.5.37/sql/item_cmpfunc.cc:4616
# 2014-05-01T11:45:21 #17 0x0000000000742f68 in Item::val_bool (this=0x7f103419acc0) at /home/prohaska/mysql-5.5.37/sql/item.cc:200
# 2014-05-01T11:45:21 #18 0x000000000076cb56 in Item_cond_or::val_int (this=0x7f103418afc0) at /home/prohaska/mysql-5.5.37/sql/item_cmpfunc.cc:4634
# 2014-05-01T11:45:21 #19 0x0000000000637970 in SQL_SELECT::skip_record (this=0x7f103419adc0, thd=0x372c500, skip_record=0x7f10456d096f) at /home/prohaska/mysql-5.5.37/sql/opt_range.h:888
# 2014-05-01T11:45:21 #20 0x000000000073384b in find_all_keys (param=0x7f10456d0ae0, select=0x7f103419adc0, sort_keys=0x7f103408b940, buffpek_pointers=0x7f10456d0c80, tempfile=0x7f10456d0b60) at /home/prohaska/mysql-5.5.37/sql/filesort.cc:657
# 2014-05-01T11:45:21 #21 0x0000000000732577 in filesort (thd=0x372c500, table=0x7f103402fda0, sortorder=0x7f103419b110, s_length=2, select=0x7f103419adc0, max_rows=18446744073709551615, sort_positions=false, examined_rows=0x7f10456d0e98) at /home/prohaska/mysql-5.5.37/sql/filesort.cc:249
# 2014-05-01T11:45:21 #22 0x000000000062b4a2 in create_sort_index (thd=0x372c500, join=0x7f1034189110, order=0x7f10340ba3e8, filesort_limit=18446744073709551615, select_limit=18446744073709551615, is_order_by=false) at /home/prohaska/mysql-5.5.37/sql/sql_select.cc:14254
# 2014-05-01T11:45:21 #23 0x000000000060e582 in JOIN::exec (this=0x7f1034189110) at /home/prohaska/mysql-5.5.37/sql/sql_select.cc:2354
# 2014-05-01T11:45:21 #24 0x000000000060ef77 in mysql_select (thd=0x372c500, rref_pointer_array=0x372e758, tables=0x7f1034055720, wild_num=0, fields=..., conds=0x7f1034056930, og_num=2, order=0x7f10340ba3e8, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7f10340ba618, unit=0x372df50, select_lex=0x372e570) at /home/prohaska/mysql-5.5.37/sql/sql_select.cc:2604
# 2014-05-01T11:45:21 #25 0x0000000000607235 in handle_select (thd=0x372c500, lex=0x372dea0, result=0x7f10340ba618, setup_tables_done_option=0) at /home/prohaska/mysql-5.5.37/sql/sql_select.cc:297
# 2014-05-01T11:45:21 #26 0x00000000005e4993 in execute_sqlcom_select (thd=0x372c500, all_tables=0x7f1034055720) at /home/prohaska/mysql-5.5.37/sql/sql_parse.cc:4625
# 2014-05-01T11:45:21 #27 0x00000000005ddd5c in mysql_execute_command (thd=0x372c500) at /home/prohaska/mysql-5.5.37/sql/sql_parse.cc:2176
# 2014-05-01T11:45:21 #28 0x00000000005e6a92 in mysql_parse (thd=0x372c500, rawbuf=0x7f1034055160 "SELECT `col_int_key` AS c1 FROM `E` WHERE `col_int_nokey`  BETWEEN `col_int_key` AND FROM_DAYS( 164 ) OR `col_date_nokey`  BETWEEN `col_datetime_nokey` AND `col_time_key` OR `col_date_key`  BETWEEN CONVERT_TZ( DATE( SEC_TO_TIME( DAYOFMONTH( DATE( `col_date_key` ) ) ) ) , 'Universal' , 'MET' ) AND `col_int_nokey` AND `col_date_key` NOT BETWEEN ADDTIME( TIMESTAMP( `pk` ) , `col_datetime_nokey` ) AND EXTRACT( DAY_MICROSECOND FROM `col_date_nokey` ) ORDER BY `pk` , `col_time_nokey`", length=482, parser_state=0x7f10456d2680) at /home/prohaska/mysql-5.5.37/sql/sql_parse.cc:5662
# 2014-05-01T11:45:21 #29 0x00000000005db510 in dispatch_command (command=COM_QUERY, thd=0x372c500, packet=0x372fc91 " SELECT `col_int_key` AS c1 FROM `E` WHERE `col_int_nokey`  BETWEEN `col_int_key` AND FROM_DAYS( 164 ) OR `col_date_nokey`  BETWEEN `col_datetime_nokey` AND `col_time_key` OR `col_date_key`  BETWEEN CONVERT_TZ( DATE( SEC_TO_TIME( DAYOFMONTH( DATE( `col_date_key` ) ) ) ) , 'Universal' , 'MET' ) AND `col_int_nokey` AND `col_date_key` NOT BETWEEN ADDTIME( TIMESTAMP( `pk` ) , `col_datetime_nokey` ) AND EXTRACT( DAY_MICROSECOND FROM `col_date_nokey` ) ORDER BY `pk` , `col_time_nokey`", packet_length=483) at /home/prohaska/mysql-5.5.37/sql/sql_parse.cc:1038
# 2014-05-01T11:45:21 #30 0x00000000005da8b3 in do_command (thd=0x372c500) at /home/prohaska/mysql-5.5.37/sql/sql_parse.cc:773
# 2014-05-01T11:45:21 #31 0x00000000006b6627 in do_handle_one_connection (thd_arg=0x372c500) at /home/prohaska/mysql-5.5.37/sql/sql_connect.cc:862
# 2014-05-01T11:45:21 #32 0x00000000006b6186 in handle_one_connection (arg=0x372c500) at /home/prohaska/mysql-5.5.37/sql/sql_connect.cc:781
# 2014-05-01T11:45:21 #33 0x0000003496a079d1 in start_thread () from /lib64/libpthread.so.0
# 2014-05-01T11:45:21 #34 0x00000034962e8b6d in clone () from /lib64/libc.so.6

How to repeat:
run this randgen test.  may take a couple of runs.

runall.pl --grammar=conf/temporal/temporal_functions.yy --duration=300 --queries=10000000 --threads=1 --basedir=/home/prohaska/mysql-5.5.37-install/ --vardir=/home/prohaska/vardir_mysql5537_temporal_functions_innodb --mysqld=--default-storage-engine=innodb --mysqld=--general_log
[18 Nov 2014 18:04] Morgan Tocker
I can reproduce this in MySQL 5.5.40 - I will upload a testcase to reproduce.  From what I can tell:

* It will only crash a debug build.
* It requires the timezone tables to be loaded.

morgo@Rbook-4:~/sandboxes/msb_5_5_40$ ./my sql_tzinfo_to_sql /usr/share/zoneinfo | ./use mysql
Warning: Unable to load '/usr/share/zoneinfo/+VERSION' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it.
---------------------------------------------------------------------------------------------------------------------------------------------------------------- 13:04:30
morgo@Rbook-4:~/sandboxes/msb_5_5_40$ ./use test < ~/Desktop/bug72503.sql
ERROR 2013 (HY000) at line 1024: Lost connection to MySQL server during query
[18 Nov 2014 18:05] Morgan Tocker
Test case to reproduce reported issue

Attachment: bug72503.sql (application/octet-stream, text), 104.67 KiB.

[18 Nov 2014 18:21] Morgan Tocker
Could not reproduce in 5.6.19 or 5.7.4.