Operating System - HP-UX
1835991 Members
3171 Online
110088 Solutions
New Discussion

Potential date issue Jan 10 2004?

 
Norman Dignard
Regular Advisor

Potential date issue Jan 10 2004?

One of our users has identified a potential problem with some of our custom apps. I'm wondering if anyone knows of any impacts/problems on HP's OS or furnished applications? Below is the problem as it was identified to me.

"On 10 January 2004, UNIX time will increase from a 30-bit number to a 31-bit number. After that time, in certain time calculations, there is a risk of sign errors or other instabilities in any UNIX-based system. This problem has only recently been discovered certain systems. Modifications are required in those systems but these modifications appear not to be major.

The calculation at risk is of the following type:

Average time AB = (Time A + Time B)/2"
5 REPLIES 5
Steven E. Protter
Exalted Contributor

Re: Potential date issue Jan 10 2004?

Hi Norman,

I have not heard that.

I am told that Unix uses a clock that started Jan 1, 1970.

That would mean that a mathematical forumla to show that the value had to be 31 bit after the date January 10, 2004.

Since it is now 31 days to that deadline I'll go out on a limb: If the problem was real, we'd know about it by now.

Looking forward to seeing the math and other comments.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Rodney Hills
Honored Contributor

Re: Potential date issue Jan 10 2004?

You are correct. The following program overflows the addition into the sign field.

int i,j,k;
main()
{
i=0x7fffffff;
j=i-12340;
k=(i+j)/2;
printf("i is %d\n", i);
printf("j is %d\n", j);
printf("k is %d\n", k);
}
$ a.out
i is 2147483647
j is 2147471307
k is -6171

Realistically though, I'm not sure how many apps would do calculations by adding 2 time values.

My 2 cents...

-- Rod Hills
There be dragons...
A. Clay Stephenson
Acclaimed Contributor

Re: Potential date issue Jan 10 2004?

That potential has always been there for the overflow of a 32-bit signed integer when adding a number of epoch seconds together. It's just that on the mentioned date, it's become a 'bit' more likely. (Sorry, I couldn't resist). On that day, epoch seconds (seconds since 00:00:00 Jan 1, 1970 UTC) exceed 1073741824. The overflow of a single UNIX 32-bit time value is still a few decades away but now adding merely two times could lead to an overflow.


If it ain't broke, I can fix that.
Michael Schulte zur Sur
Honored Contributor

Re: Potential date issue Jan 10 2004?

Hi,

thats certainly worth looking for.
Easy workaroud:
Average time AB = Time A + (Time B - Time A)/2".

be happy,

Michael
Elmar P. Kolkman
Honored Contributor

Re: Potential date issue Jan 10 2004?

It means the application is written wrong, off course... Just a matter of putting the time values in a unsigned, or even better a 64 bit integer (long), can solve the issue off course. I'm not sure, but I was under the impression that some of the 64-bit OS's already put the time in 64 bits, meaning it is not an issue for a long time.

/usr/include/sys/_time_t.h can give you some answers. Right here I have both 10.20 and 11 systems that use a long for time_t, the type used for time values... So no problem there.
Every problem has at least one solution. Only some solutions are harder to find.