Bug 63369

Summary: mktime seems to have changed between glibc-2.2.5-30 and glibc-2.2.5-32
Product: [Retired] Red Hat Linux Reporter: Chip Turner <cturner>
Component: glibcAssignee: Jakub Jelinek <jakub>
Status: CLOSED RAWHIDE QA Contact: Brian Brock <bbrock>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.3CC: fweimer
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2002-04-15 03:31:59 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 63361    
Bug Blocks: 61590    

Description Chip Turner 2002-04-13 00:20:05 UTC
Description of Problem:
mktime has changed and is returning different values between the mentioned
versions of glibc.  Affects i386 and ia64 and perhaps more.  Demonstration
program and output when run on boris (glibc 2.2.5-30, but 2.2.5-32 inside buildroot)

#include <time.h>
#include <stdio.h>

int
main()
{
        struct tm t;
        time_t result;
        t.tm_sec = 59;
        t.tm_min = 59;
        t.tm_hour = 23;
        t.tm_mday = 31;
        t.tm_mon = 11;
        t.tm_year = 69;

        result = mktime(&t);

        printf("time: %ld, %s", (long)result, ctime(&result));

        return 1;
}


[cturner@boris cturner]$ gcc -Wall test.c -o test
[cturner@boris cturner]$ ./test
time: 17999, Wed Dec 31 23:59:59 1969
[cturner@boris cturner]$ cp tes
[cturner@boris cturner]$ sudo /usr/sbin/chroot /mnt/build/beehive/dist-7.3-build/
[cturner@boris cturner]$ cp test.c /mnt/build/beehive/dist-7.3-build/tmp
[cturner@boris cturner]$ sudo su -
[root@boris root]# chroot /mnt/build/beehive/dist-7.3-build 
[root@boris /]# cd /tmp
[root@boris tmp]# gcc -Wall test.c -o test
[root@boris tmp]# ./test
time: -1, Wed Dec 31 18:59:59 1969

Comment 1 Chip Turner 2002-04-13 00:20:55 UTC
marked 63361 as depending on this

Comment 2 Jakub Jelinek 2002-04-13 00:57:19 UTC
Yes, this has changed.
See http://bugs.gnu.org/cgi-bin/gnatsweb.pl?debug=&database=default&cmd=view+audit-trail&cmd=view&pr=2738
            A value that approximates the number of seconds that have
            elapsed since the Epoch. A Coordinated Universal Time name
            (specified in terms of seconds (tm_sec), minutes (tm_min),
            hours (tm_hour), days since January 1 of the year (tm_yday),
            and calendar year minus 1900 (tm_year)) is related to a time
            represented as seconds since the Epoch, according to the
            expression below.

            If the year is <1970 or the value is negative, the
            relationship is undefined. If the year is 1970 and the value
            is non-negative, the value is related to a Coordinated
            Universal Time name according to the C-language expression,
            where tm_sec, tm_min, tm_hour, tm_yday, and tm_year are all

  And mktime is defined as:

    The mktime( ) function shall return the specified time since the
    Epoch encoded as a value of type time_t. If the time since the Epoch
    cannot be represented, the function shall return the value
    (time_t)-1.

  tm_year=69 means a year < 1970 and therefore undefined and cannot be
  represented.

Was this some standard conformance suite or what have you used to find out
about this?

Comment 3 Bill Nottingham 2002-04-13 01:00:21 UTC
The time passed is interpreted as in the current timezone. Hence, the time since
the epoch *can* be represented.

Comment 4 Bill Nottingham 2002-04-13 01:06:20 UTC
As to what prompted this, this is what causes perl-Date-Calc to fail building,
as its test suite fails.

Comment 5 Jakub Jelinek 2002-04-13 21:24:35 UTC
http://sources.redhat.com/ml/libc-hacker/2002-04/msg00053.html
was added into glibc-2.2.5-33. Can you please check it out?

Comment 6 Chip Turner 2002-04-14 02:47:07 UTC
Looks good, output of test.c on my workstation with glibc-2.2.5-33 is:
[cturner@minbar cturner]$ ./test
time: 17999, Wed Dec 31 23:59:59 1969

perl-Date-Calc also passes its tests now