Bug #55755 Date STD variable signness breaks server on FreeBSD and OpenBSD
| Submitted: | 5 Aug 2010 2:48 | Modified: | 2 Mar 2011 15:43 |
|---|---|---|---|
| Reporter: | Weyoun Washington | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | MySQL Server: General | Severity: | S2 (Serious) |
| Version: | 5.1.49, 5.1.54 | OS: | FreeBSD (and OpenBSD amd64) |
| Assigned to: | Georgi Kodinov | CPU Architecture: | Any |
| Tags: | Contribution, date | ||
[8 Sep 2010 10:08]
Valeriy Kravchuk
Please, send the results of uname -a from all systems affected. I want to know is it 64-bit only issue.
[8 Oct 2010 23:00]
Bugs System
No feedback was provided for this bug for over a month, so it is being suspended automatically. If you are able to provide the information that was originally requested, please do so and change the status of the bug back to "Open".
[25 Oct 2010 7:30]
Giovanni Bechis
Here is a system affected by this bug (on 5.1.51 too): OpenBSD bigio.snb.it 4.8 GENERIC.MP#3 amd64 The problem is not present on OpenBSD i386. On OpenBSD-amd64 time_t is defined as int, LONG_MIN is (-0x7fffffffffffffffL-1) and LONG_MAX is 0x7fffffffffffffffL. See http://bugs.mysql.com/bug.php?id=55538 for other informations.
[13 Dec 2010 9:18]
Ian McWilliam
Still busted with MySQL 5.1.53
101213 20:08:03 mysqld_safe Starting mysqld daemon with databases from /var/mysql
101213 20:08:03 [ERROR] This MySQL server doesn't support dates later then 2038
101213 20:08:03 [ERROR] Aborting
Segmentation fault (core dumped)
101213 20:08:03 mysqld_safe mysqld from pid file /var/mysql/xena.mcw.com.au.pid ended
101213 20:08:53 mysqld_safe Starting mysqld daemon with databases from /var/mysql
101213 20:08:53 [ERROR] This MySQL server doesn't support dates later then 2038
101213 20:08:53 [ERROR] Aborting
Segmentation fault (core dumped)
xena:mysql {132} uname -a
OpenBSD xena.mcw.com.au 4.8 GENERIC.MP#0 amd64
[2 Jan 2011 20:15]
Valeriy Kravchuk
Verified just as described with 5.1.54 on 64-bit OpenBSD 4.8 amd64. Thank you for your contribution and patience.
[2 Jan 2011 20:22]
Valeriy Kravchuk
Bug #55538 was marked as a duplicate of this one.
[3 Jan 2011 0:58]
Weyoun Washington
Update: GCC's int type is 32 bit on both i386 and amd64, where as the long type is the processor's word size. And because the point of MY_TIME_T_MAX is to corral timestamps to 32 bits, the most proper fix would actually be #define MY_TIME_T_MAX INT_MAX #define MY_TIME_T_MIN INT_MIN
[5 Jan 2011 15:39]
Georgi Kodinov
This is a regression from bug #52315. Changing target to 5.0+
[5 Jan 2011 18:08]
Georgi Kodinov
One notable difference between openbsd and MacOSX is that sizeof(time_t) is 4 in openbsd and 8 in MacOSX.
[6 Jan 2011 16:20]
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/128103 2895 Georgi Kodinov 2011-01-06 Fixes for Bug #55755 and Bug #52315 part 2 Bug #55755 : Date STD variable signness breaks server on FreeBSD and OpenBSD * Added a check to configure on the size of time_t * Created a macro to check for a valid time_t that can fit into a my_time_t * Used the macro consistently instead of the ad-hoc checks introduced by 52315 * Fixed compliation warnings on platforms where the size of time_t is smaller than the size of a long (e.g. OpenBSD 4.8 64 amd64). Bug #52315: utc_date() crashes when system time > year 2037 * Added a correct check for the timestamp range instead of just variable size check to SET TIMESTAMP. * Added a test suite.
[17 Jan 2011 16: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/128995 2895 Georgi Kodinov 2011-01-17 Fixes for Bug #55755 and Bug #52315 part 2 Bug #55755 : Date STD variable signness breaks server on FreeBSD and OpenBSD * Added a check to configure on the size of time_t * Created a macro to check for a valid time_t that can fit into a my_time_t * Used the macro consistently instead of the ad-hoc checks introduced by 52315 * Fixed compliation warnings on platforms where the size of time_t is smaller than the size of a long (e.g. OpenBSD 4.8 64 amd64). Bug #52315: utc_date() crashes when system time > year 2037 * Added a correct check for the timestamp range instead of just variable size check to SET TIMESTAMP. * Added overflow checking before converting to time_t. * Using a correct localized error message in this case instead of the generic error. * Added a test suite.
[2 Feb 2011 14:31]
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/130241 2895 Georgi Kodinov 2011-02-02 Fixes for Bug #55755 and Bug #52315 part 2 Bug #55755 : Date STD variable signness breaks server on FreeBSD and OpenBSD * Added a check to configure on the size of time_t * Created a macro to check for a valid time_t that can fit into a my_time_t * Used the macro consistently instead of the ad-hoc checks introduced by 52315 * Fixed compliation warnings on platforms where the size of time_t is smaller than the size of a long (e.g. OpenBSD 4.8 64 amd64). Bug #52315: utc_date() crashes when system time > year 2037 * Added a correct check for the timestamp range instead of just variable size check to SET TIMESTAMP. * Added overflow checking before converting to time_t. * Using a correct localized error message in this case instead of the generic error. * Added a test suite. * fixed the checks so that they check for unsigned time_t as well. Used the checks consistently across the source code.
[2 Feb 2011 16:02]
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/130255 2899 Georgi Kodinov 2011-02-02 Fixes for Bug #55755 and Bug #52315 part 2 Bug #55755 : Date STD variable signness breaks server on FreeBSD and OpenBSD * Added a check to configure on the size of time_t * Created a macro to check for a valid time_t that is safe to use with datetime functions and store in TIMESTAMP columns. * Used the macro consistently instead of the ad-hoc checks introduced by 52315 * Fixed compliation warnings on platforms where the size of time_t is smaller than the size of a long (e.g. OpenBSD 4.8 64 amd64). Bug #52315: utc_date() crashes when system time > year 2037 * Added a correct check for the timestamp range instead of just variable size check to SET TIMESTAMP. * Added overflow checking before converting to time_t. * Using a correct localized error message in this case instead of the generic error. * Added a test suite. * fixed the checks so that they check for unsigned time_t as well. Used the checks consistently across the source code.
[2 Feb 2011 16:52]
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/130262 2899 Georgi Kodinov 2011-02-02 Fixes for Bug #55755 and Bug #52315 part 2 Bug #55755 : Date STD variable signness breaks server on FreeBSD and OpenBSD * Added a check to configure on the size of time_t * Created a macro to check for a valid time_t that is safe to use with datetime functions and store in TIMESTAMP columns. * Used the macro consistently instead of the ad-hoc checks introduced by 52315 * Fixed compliation warnings on platforms where the size of time_t is smaller than the size of a long (e.g. OpenBSD 4.8 64 amd64). Bug #52315: utc_date() crashes when system time > year 2037 * Added a correct check for the timestamp range instead of just variable size check to SET TIMESTAMP. * Added overflow checking before converting to time_t. * Using a correct localized error message in this case instead of the generic error. * Added a test suite. * fixed the checks so that they check for unsigned time_t as well. Used the checks consistently across the source code. * fixed the original test case to expect the new error code.
[2 Feb 2011 18:32]
Bugs System
Pushed into mysql-5.0 5.0.93 (revid:georgi.kodinov@oracle.com-20110202181057-x9aqy01fb2t5xm2n) (version source revid:georgi.kodinov@oracle.com-20110202165135-8hieawdkp931quj0) (merge vers: 5.0.93) (pib:24)
[2 Feb 2011 18:32]
Bugs System
Pushed into mysql-5.1 5.1.56 (revid:georgi.kodinov@oracle.com-20110202181311-43bd41beoas8nlcd) (version source revid:georgi.kodinov@oracle.com-20110202170528-gm46bal54qpnsehp) (merge vers: 5.1.56) (pib:24)
[2 Feb 2011 18:33]
Bugs System
Pushed into mysql-5.5 5.5.10 (revid:georgi.kodinov@oracle.com-20110202181606-hi05so9jg3q05486) (version source revid:georgi.kodinov@oracle.com-20110202181328-vw3wyjzm6yzxpcs3) (merge vers: 5.5.10) (pib:24)
[2 Feb 2011 18:33]
Bugs System
Pushed into mysql-trunk 5.6.2 (revid:georgi.kodinov@oracle.com-20110202183139-ykxq0tjd2vo3km91) (version source revid:georgi.kodinov@oracle.com-20110202183139-ykxq0tjd2vo3km91) (merge vers: 5.6.2) (pib:24)
[2 Mar 2011 15:43]
Paul DuBois
Noted in 5.0.93, 5.1.56, 5.5.10, 5.6.2 changelogs. On FreeBSD and OpenBSD, the server incorrectly checked the range of the system date, causing legal values to be rejected. CHANGESET - http://lists.mysql.com/commits/130262
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.102 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.
Description: When the server checks to see if the system's date isn't beyond safe boundaries, it rejects any date. This WILL prevent the daemon from running on affected systems/builds. How to repeat: Compile and run the latest server on the latest OpenBSD or FreeBSD. Suggested fix: It the file ./include/my_time.h where it says #define MY_TIME_T_MAX LONG_MAX #define MY_TIME_T_MIN LONG_MIN replace it with #define MY_TIME_T_MAX 2147483647 #define MY_TIME_T_MIN 0 In the file ./sql/mysqld.cc on line 3244, which says if (server_start_time >= (time_t) MY_TIME_T_MAX) replace it with if (server_start_time > (time_t) MY_TIME_T_MAX) In the file ./sql/sql_class.h on line 2035, where it says return (start_time < (time_t) MY_TIME_T_MAX); replace it with return (start_time <= (time_t) MY_TIME_T_MAX); I tested the fix, it does work, and it's completely portable.