[akr@m17n.org: bin/27630: mktime problem.]

A FreeBSD user submitted the following bug report. I'm curious as to whether the current tzcode still has this problem. My analysis follows at the end. -GAWollman ------- start of forwarded message (RFC 934 encapsulation) ------- Message-Id: <20010525021018.01D54727@flux.etl.go.jp> Reply-To: akr@m17n.org X-Send-Pr-Version: 3.2 List-ID: <freebsd-bugs.FreeBSD.ORG> List-Archive: <http://docs.freebsd.org/mail/> (Web Archive) List-Help: <mailto:majordomo?subject=help> (List Instructions) List-Subscribe: <mailto:majordomo?subject=subscribe%20freebsd-bugs> List-Unsubscribe: <mailto:majordomo?subject=unsubscribe%20freebsd-bugs> X-Loop: FreeBSD.org Precedence: bulk From: akr@m17n.org Sender: owner-freebsd-bugs@FreeBSD.ORG To: FreeBSD-gnats-submit@FreeBSD.ORG Subject: bin/27630: mktime problem. Date: Fri, 25 May 2001 11:10:18 +0900 (JST)
Number: 27630 Category: bin Synopsis: mktime failure. Confidential: no Severity: serious Priority: medium Responsible: freebsd-bugs State: open Quarter: Keywords: Date-Required: Class: sw-bug Submitter-Id: current-users Arrival-Date: Thu May 24 19:20:00 PDT 2001 Closed-Date: Last-Modified: Originator: Tanaka Akira Release: FreeBSD 4.2-RELEASE i386 Organization: m17n Environment:
FreeBSD flux 4.2-RELEASE FreeBSD 4.2-RELEASE #2: Fri Jan 12 22:55:02 JST 2001 akr@flux:/usr/src/sys/compile/AKR i386
Description:
mktime(3) fails on some condition. For example, TZ=Africa/Monrovia, 1972/05/01 00:44:30 cannot be converted to time_t. Since this example is taken from `zdump -v Africa/Monrovia' and it is after Epoch, there is no reason to fail. Actually, I tested all time listed in `zdump -v' for each timezone in /usr/share/zoneinfo and found many failures. Above failure is one of them.
How-To-Repeat:
% cat tst.c #include <stdio.h> #include <time.h> int main() { struct tm a; time_t t; a.tm_year = 1972 - 1900; a.tm_mon = 5 - 1; a.tm_mday = 1; a.tm_hour = 0; a.tm_min = 44; a.tm_sec = 30; a.tm_wday = 0; a.tm_yday = 0; a.tm_isdst = -1; t = mktime(&a); if (t == -1) { perror("mktime"); exit(1); } printf("no problem\n"); return 0; } % gcc tst.c % TZ=Africa/Monrovia ./a.out mktime: Undefined error: 0 %
Fix:
Release-Note: Audit-Trail: Unformatted:
To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message ------- end ------- This problem appears to result from the `saved_seconds' hackery in time2(): saved_seconds = yourtm.tm_sec; yourtm.tm_sec = 0; time2() then goes on to attempt to find (in this example) 1972-05-01T00:44:00, which does not exist in this time zone, and returns failure. -GAWollman
participants (1)
-
Garrett Wollman