Bug #28641 | CREATE EVENT with '2038.01.18 03:00:00' let server crash. | ||
---|---|---|---|
Submitted: | 24 May 2007 8:10 | Modified: | 2 Aug 2007 3:46 |
Reporter: | Horst Hunger | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Stored Routines | Severity: | S1 (Critical) |
Version: | 5.1.19 | OS: | Linux (suse 10.1) |
Assigned to: | Kristofer Pettersson | CPU Architecture: | Any |
[24 May 2007 8:10]
Horst Hunger
[24 May 2007 9:44]
Valeriy Kravchuk
Thank you for a problem report. Sorry, but I was not able to repeat the crash with latest 5.1.19-BK: openxs@suse:~/dbs/5.1/mysql-test> ./mysql-test-run.pl --force bug28641 Logging: ./mysql-test-run.pl --force bug28641 070517 13:27:24 [Warning] Server variable data_file_path of plugin InnoDB was fo rced to be read-only: string variable without update_func and PLUGIN_VAR_MEMALLO C flag 070517 13:27:24 [Warning] Server variable data_home_dir of plugin InnoDB was for ced to be read-only: string variable without update_func and PLUGIN_VAR_MEMALLOC flag 070517 13:27:24 [Warning] Server variable flush_method of plugin InnoDB was forc ed to be read-only: string variable without update_func and PLUGIN_VAR_MEMALLOC flag 070517 13:27:24 [Warning] Server variable log_arch_dir of plugin InnoDB was forc ed to be read-only: string variable without update_func and PLUGIN_VAR_MEMALLOC flag 070517 13:27:24 [Warning] Server variable log_group_home_dir of plugin InnoDB wa s forced to be read-only: string variable without update_func and PLUGIN_VAR_MEM ALLOC flag 070517 13:27:24 [Note] /home/openxs/dbs/5.1/libexec/mysqld: Shutdown complete MySQL Version 5.1.19 Using binlog format 'mixed' Using ndbcluster when necessary, mysqld supports it Skipping SSL, mysqld not compiled with SSL mysql-test-run: WARNING: Could not find all required ndb binaries, all ndb tests will fail, use --skip-ndbcluster to skip testing it. Using MTR_BUILD_THREAD = 0 Using MASTER_MYPORT = 9306 Using MASTER_MYPORT1 = 9307 Using SLAVE_MYPORT = 9308 Using SLAVE_MYPORT1 = 9309 Using SLAVE_MYPORT2 = 9310 Using NDBCLUSTER_PORT = 9310 Using NDBCLUSTER_PORT_SLAVE = 9311 Using IM_PORT = 9312 Using IM_MYSQLD1_PORT = 9313 Using IM_MYSQLD2_PORT = 9314 Killing Possible Leftover Processes Removing Stale Files Creating Directories Installing Master Database Installing Master Database Saving snapshot of installed databases ======================================================= Starting Tests in the 'main' suite TEST RESULT TIME (ms) ------------------------------------------------------- bug28641 [ fail ] Errors are (from /home/openxs/dbs/5.1/mysql-test/var/log/mysqltest-time) : mysqltest: Result length mismatch (the last lines may be the most important ones) Below are the diffs between actual and expected results: ------------------------------------------------------- *** r/bug28641.result 2007-05-17 13:27:22.000000000 +0300 --- r/bug28641.reject 2007-05-17 13:27:25.000000000 +0300 *************** *** 0 **** --- 1,37 ---- + DROP SCHEMA IF EXISTS event_test; + CREATE SCHEMA event_test; + USE event_test; + SET GLOBAL event_scheduler = ON; + CREATE TABLE event_log (id int KEY AUTO_INCREMENT, ev_nm char(40), ev_cnt int, ev_tm timestamp) ENGINE=MyISAM; + SET @ev_base_date = 20281224180000; + CREATE EVENT ev_create_11364 ON SCHEDULE AT '2038.01.18 02:59:59' + DO BEGIN + SET @evname = 'ev_create_11364'; + SET @cnt = 0; + SELECT count(*) into @cnt from event_log where ev_nm = @evname ; + INSERT INTO event_log VALUES (NULL,@evname,@cnt+1,current_timestamp()); + END;| + CREATE EVENT ev_create_11365 ON SCHEDULE AT '2038.01.18 03:00:00' + DO BEGIN + SET @evname = 'ev_create_11365'; + SET @cnt = 0; + SELECT count(*) into @cnt from event_log where ev_nm = @evname ; + INSERT INTO event_log VALUES (NULL,@evname,@cnt+1,current_timestamp()); + END;| + CREATE EVENT ev_create_11366 ON SCHEDULE AT '2038.01.19 06:14:07' + DO BEGIN + SET @evname = 'ev_create_11366'; + SET @cnt = 0; + SELECT count(*) into @cnt from event_log where ev_nm = @evname ; + INSERT INTO event_log VALUES (NULL,@evname,@cnt+1,current_timestamp()); + END;| + CREATE EVENT ev_create_11366 ON SCHEDULE AT '2038.01.19 06:14:08' + DO BEGIN + SET @evname = 'ev_create_11366'; + SET @cnt = 0; + SELECT count(*) into @cnt from event_log where ev_nm = @evname ; + INSERT INTO event_log VALUES (NULL,@evname,@cnt+1,current_timestamp()); + END;| + ERROR HY000: Incorrect AT value: '2038.01.19 06:14:08' + SET GLOBAL event_scheduler = OFF; + DROP SCHEMA event_test; ------------------------------------------------------- Please follow the instructions outlined at http://www.mysql.com/doc/en/Reporting_mysqltest_bugs.html to find the reason to this problem and how to report this. Result from queries before failure can be found in /home/openxs/dbs/5.1/mysql-te st/var/log/bug28641.log Stopping All Servers Restoring snapshot of databases Resuming Tests ------------------------------------------------------- Stopping All Servers Failed 1/1 tests, 0.00% were successful. The log files in var/log may give you some hint of what went wrong. If you want to report this error, please read first the documentation at http://www.mysql.com/doc/en/MySQL_test_suite.html The servers were restarted 1 times Spent 0 seconds actually executing testcases mysql-test-run in default mode: *** Failing the test(s): bug28641 mysql-test-run: *** ERROR: there were failing test cases There were no crash.
[6 Jun 2007 8:35]
Andrey Hristov
Verified here with 5.1.20-dev #0 0xffffe410 in __kernel_vsyscall () #1 0x400fb2c1 in raise () from /lib/tls/libc.so.6 #2 0x400fcb75 in abort () from /lib/tls/libc.so.6 #3 0x400f4903 in __assert_fail () from /lib/tls/libc.so.6 #4 0x083bfba2 in sec_since_epoch (year=2038, mon=1, mday=18, hour=0, min=6, sec=6) at tztime.cc:790 #5 0x083bfcaa in sec_since_epoch_TIME (t=0x6) at tztime.cc:818 #6 0x083db9f5 in Event_queue_element::load_from_row (this=0x890cb98, thd=0x0, table=0x88e2a10) at event_data_objects.cc:975 #7 0x083e101f in Event_db_repository::load_named_event (this=0x88b2818, thd=0x88c3c38, dbname=The value of variable 'dbname' is distributed across several locations, and GDB cannot access its value. ) at event_db_repository.cc:889 #8 0x083e2426 in Events::create_event (thd=0x88c3c38, parse_data=0x89080b8, if_not_exists=false) at events.cc:412 #9 0x0823d3dc in mysql_execute_command (thd=0x88c3c38) at sql_parse.cc:3247 #10 0x08242744 in mysql_parse (thd=0x88c3c38, inBuf=0x8903618 "CREATE EVENT ev_create_11365 ON SCHEDULE AT '2038.01.18 03:00:00'\n", ' ' <repeats 12 times>, "DO BEGIN\nSET @evname = 'ev_create_11365';\nSET @cnt = 0;\nSELECT count(*) into @cnt from event_log where ev_nm = @evname ;\nI"..., length=274, found_semicolon=0x4055af78) at sql_parse.cc:5381 #11 0x08237df0 in dispatch_command (command=COM_QUERY, thd=0x88c3c38, packet=0x88e7cb1 "CREATE EVENT ev_create_11365 ON SCHEDULE AT '2038.01.18 03:00:00'\n", ' ' <repeats 12 times>, "DO BEGIN\nSET @evname = 'ev_create_11365';\nSET @cnt = 0;\nSELECT count(*) into @cnt from event_log where ev_nm = @evname ; Quit ) at sql_parse.cc:907 #12 0x08237553 in do_command (thd=0x88c3c38) at sql_parse.cc:669 #13 0x0823609f in handle_one_connection (arg=0x0) at sql_connect.cc:1091 #14 0x40053aa7 in start_thread () from /lib/tls/libpthread.so.0 #15 0x4018dc2e in clone () from /lib/tls/libc.so.6
[6 Jun 2007 12:12]
Andrey Hristov
Just CREATE EVENT ev_create_11365 ON SCHEDULE AT '2038.01.18 03:00:00' DO BEGIN SET @evname = 'ev_create_11365'; SET @cnt = 0; SELECT count(*) into @cnt from event_log where ev_nm = @evname ; INSERT INTO event_log VALUES (NULL,@evname,@cnt+1,current_timestamp()); END;| Causes a segfault. Date handling is not good for 2003-01-17 , 18 and 19
[14 Jun 2007 20:53]
Andrey Hristov
2003 is a typo, I mean 2038
[21 Jun 2007 11:12]
Dmitry Lenev
After short investigation I think that problem stems from the fact that events implementation uses sec_since_epoch_TIME() function which is a thin wrapper around of sec_since_epoch() function. The latter is private function of code implementating time zone support and therefore makes some assumptions about its arguments which do not hold in general case. I think that solution to this problem is to use Time_zone_utc::TIME_to_gmt_sec() for "UTC datetime -> time_t" conversions in events code instead of sec_since_epoch_TIME() (indeed we will have to implement it first). Especially since for "time_t -> UTC datetime" conversions this code already uses Time_zone_utc::gmt_sec_to_TIME() method. Note that we can't implement Time_zone_utc::TIME_to_gmt_sec() method simply as wrapper to sec_since_epoch() function, since on systems with leap seconds the latter is not inverse of Time_zone_utc::gmt_sec_to_TIME().
[24 Jul 2007 13:44]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/31476 ChangeSet@1.2556, 2007-07-24 15:43:46+02:00, thek@adventure.(none) +7 -0 Bug#28641 CREATE EVENT with '2038.01.18 03:00:00' let server crash. Creating an EVENT to be executed at a time close to the end of the allowed range (2038.01.19) would cause the server to crash. The expected behavior is to accept all calendar times within the interval and reject all other values without crashing. This patch replaces the function 'sec_to_epoch_TIME' with the Time_zone API. This function was broken because it invoked the internal function 'sec_to_epoch' without respecting the restrictions on the function parameters. It also was used as a reverse function to Time_zone_utc::gmt_sec_to_TIME which it isn't.
[25 Jul 2007 7:44]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/31530 ChangeSet@1.2556, 2007-07-25 09:43:49+02:00, thek@adventure.(none) +7 -0 Bug#28641 CREATE EVENT with '2038.01.18 03:00:00' let server crash. Creating an EVENT to be executed at a time close to the end of the allowed range (2038.01.19 03:14:07 UTC) would cause the server to crash. The expected behavior is to accept all calendar times within the interval and reject all other values without crashing. This patch replaces the function 'sec_to_epoch_TIME' with a Time_zone API call. This function was broken because it invoked the internal function 'sec_to_epoch' without respecting the restrictions on the function parameters (and this caused assertion failure). It also was used as a reverse function to Time_zone_utc::gmt_sec_to_TIME which it isn't.
[1 Aug 2007 23:27]
Bugs System
Pushed into 5.1.21-beta
[2 Aug 2007 3:46]
Paul DuBois
Noted in 5.1.21 changelog.