Bug 27630

Summary: mktime failure.
Product: Base System Reporter: akr <akr>
Component: binAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.2-RELEASE   
Hardware: Any   
OS: Any   

Description akr 2001-05-25 03:20:00 UTC
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
%
Comment 1 Garrett A. Wollman 2001-05-25 18:02:37 UTC
<<On Fri, 25 May 2001 11:10:18 +0900 (JST), akr@m17n.org said:

> mktime(3) fails on some condition.

I am unable to duplicate your problem on a 4.2-STABLE system.  I
suggest, however, that in the future you completely initialize your
`struct tm', as you may be relying on undefined behavior.

-GAWollman
Comment 2 Garrett A. Wollman 2001-05-25 18:08:21 UTC
<<On Fri, 25 May 2001 11:10:18 +0900 (JST), akr@m17n.org said:

> mktime(3) fails on some condition.

Actually, I retract my previous statement.  I can indeed reproduce
this bug.  I'll ask on the timezone mailing-list whether it is present
in the current tzcode.

-GAWollman
Comment 3 Garrett Wollman freebsd_committer freebsd_triage 2001-06-05 21:48:33 UTC
State Changed
From-To: open->feedback

A fix from the maintainer was committed to current.  Does this fix resolve 
your problem?
Comment 4 Bruce A. Mah freebsd_committer freebsd_triage 2002-01-12 18:50:57 UTC
State Changed
From-To: feedback->closed

Feedback timeout (6 months).