The Year 2038 Problem

Discussion in 'Information Technology' started by pradeep, Jun 7, 2005.

  1. pradeep

    pradeep Team Leader

    Joined:
    Apr 4, 2005
    Messages:
    1,645
    Likes Received:
    87
    Trophy Points:
    0
    Occupation:
    Programmer
    Location:
    Kolkata, India
    Home Page:
    http://blog.pradeep.net.in
    Did you know that the year 2038 is again the replica of Y2K.......? Read on....


    The Year 2038 Problem

    Test it now...

    steps...

    Disclaimer : This is just for FYI only, Please Don't try this. This is true and if you do this then your network based applications will not work.


    1. login to yahoo messenger

    2. send instant message to anyone - fine its working...

    3. now, change ur system date to 19-Jan-2038, 03:14:07 AM or above (as mentioned in mail)

    4. Confirm weather ur date is changed

    5. again send instant message to anyone...

    Your YM crahes....

    * * * YES ALL NETWORK BASED APPLICATION WILL NOT WORK NOW * * *

    Why.....

    What is it?

    Starting at GMT 03:14:07, Tuesday, January 19, 2038, It is expected to see lots of systems around the world breaking magnificently: satellites falling out of orbit, massive power outages(like the 2003 North American blackout), hospital life support system failures, phone system interruptions,banking errors, etc. One second after this critical second, many of these systems will have wildly inaccurate date settings, producing all kinds of predictable consequences. In short, many of the dire predictions for the year 2000 are much more likely to actually occur in the year 2038! Consider the year 2000 just a dry run. In case you think we can sit on this issue for another 30 years before addressing it, consider that reports of temporal echoes of the 2038 problem are already starting to appear in future date calculations for mortgages and vital statistics!


    In the first month of the year 2038 C.E. many computers will encounter a date-related bug in their operating systems and/or in the applications they run. This can result in incorrect and wildly inaccurate dates being reported by the operating system and/or applications. The effect of this bug is hard to predict, because many applications are not prepared for the
    resulting "skip" in reported time anywhere from 1901 to a "broken record" repeat of the reported time at the second the bug occurs. Also, may make some small adjustment to the actual time the bug expresses itself. This bug to cause serious problems on many platforms, especially Unix and Unix-like platforms, because these systems will "run out of time".


    What causes it?

    Time_t is a data type used by C and C++ programs to represent dates and times internally. (Windows programmers out there might also recognize it as the basis for the CTime and CTimeSpan classes in MFC.) time_t is actually just an integer, a whole number, that counts the number of seconds since January 1, 1970 at 12:00 AM Greenwich Mean Time. A time_t value of 0 would be 12:00:00 AM (exactly midnight) 1-Jan-1970, a time_t value of 1 would be 12:00:01 AM (one second after midnight) 1-Jan-1970, etc..

    some example times and their exact time_t representations:

    Date & time time_t representation

    1-Jan-1970, 12:00:00 AM GMT 0
    1-Jan-1970, 12:01:00 AM GMT 60
    1-Jan-1970, 01:00:00 AM GMT 3 600
    2-Jan-1970, 12:00:00 AM GMT 86 400
    1-Jan-1971, 12:00:00 AM GMT 31 536 000
    1-Jan-1972, 12:00:00 AM GMT 63 072 000
    1-Jan-2038, 12:00:00 AM GMT 2 145 916 800
    19-Jan-2038, 03:14:07 AM GMT 2 147 483 647


    By the year 2038, the time_t representation for the current time will be over 2 140 000 000. And that's the problem. A modern 32-bit computer stores a "signed integer" data type, such as time_t, in 32 bits. The first of these bits is used for the positive/negative sign of the integer, while the remaining 31 bits are used to store the number itself.

    The highest number these 31 data bits can store works out to exactly 2 147 483 647. A time_t value of this exact number, 2 147 483 647,represents January 19, 2038, at 7 seconds past 3:14 AM Greenwich Mean Time. So, at 3:14:07 AM GMT on that fateful day, every time_t used in a 32-bit C or C++ program will reach its upper limit.

    One second later, on 19-January-2038 at 3:14:08 AM GMT, disaster strikes.

    When a signed integer reaches its maximum value and then gets incremented, it wraps around to its lowest possible negative value.This means a 32-bit signed integer, such as a time_t, set to its maximum value of 2 147 483 647 and then incremented by 1, will become -2 147 483 648.
    Note that "-" sign at the beginning of this large number. A time_t value of -2 147 483 648 would represent December 13, 1901 at 8:45:52 PM GMT.


    So, if all goes normally, 19-January-2038 will suddenly become 13-December-1901 in every time_t across the globe, and every date calculation based on this figure will go haywire. And it gets worse.Most of the support functions that use the time_t data type cannot handle
    negative time_t values at all. They simply fail and return an error code.


    A quick check with the following Perl script may help determine if your computers will have problems (this requires Perl to be installed on your system, of course):

    Code:
    #!/usr/bin/perl
     
    # Use POSIX (Portable Operating System Interface) use POSIX;
     
    # Set the Time Zone to GMT (Greenwich Mean Time) for date calculations.
     
    $ENV{'TZ'} = "GMT";
     
    # Count up in seconds of Epoch time just before and after the critical event.
     
    for ($clock = 2147483641; $clock < 2147483651; $clock++)
     
    {
     
       print ctime($clock);
     
    }
     
    For example, the output of this script on Debian GNU/Linux (kernel 2.4.22) (An affected system) will be


    Code:
    # ./2038.pl
     
     
    Tue Jan 19 03:14:01 2038 
    Tue Jan 19 03:14:02 2038
    Tue Jan 19 03:14:03 2038
    Tue Jan 19 03:14:04 2038
    Tue Jan 19 03:14:05 2038
    Tue Jan 19 03:14:06 2038
    Tue Jan 19 03:14:07 2038
    Fri Dec 13 20:45:52 1901
    Fri Dec 13 20:45:52 1901
    Fri Dec 13 20:45:52 1901

    Solution

    "The best way to predict the future is to engineer it." Consider testing your ssion-critical code well ahead of time on a non-production test platform set just before the critical date. For more general applications, just using large types for storing dates will do the trick in most cases.

    For example, in GNU C, 64-bits (a "long " type) is sufficient to keep the time from rolling over for literally geological eons This just means any executables the operating systems runs will always get the correct time reported to them when queried in the correct manner.
    It doesn't stop the executables you may still want to be worried about Well-written programs can simply be recompiled with a new version of the library that uses, for example, 8-byte values for the storage format. This is possible because the library encapsulates the whole time activity with its own time types and functions (unlike most mainframe programs, which did not standardize their date formats or calculations). So the Year 2038 problem should not
    be nearly as hard to fix as the Y2K problem was.

    Admittedly, some don't feel that this impending disaster will strike too many people. They reason that, by the time 2038 rolls around, most programs will be running on 64-bit or even 128-bit computers.
    In a 64-bit program, a time_t could represent any date and time in the future out to 292
    000 000 000 A.D., which is about 20 times the currently estimated age of the universe. The problem with this kind of optimism is the same root problem behind most of the Year 2000 concerns that plagued the software industry in previous years:
    Legacy Code. Even if every PC in the year 2038 has a 64-bit CPU, there will be a lot of older 32-bit programs running on them.

    The greatest danger with the Year 2038 Problem is its invisibility. The more-famous Year 2000 is a big, round number; it only takes a few seconds of thought, even for a computer-illiterate person, to imagine what might happen when 1999 turns into 2000. But January 19, 2038 is not nearly as obvious. Software companies will probably not think of trying out a Year 2038 scenario before doomsday strikes. Of course, there will be some warning ahead of time. Scheduling software, billing programs, personal reminder calendars, and other such pieces of code that set dates in the near future will fail as soon as one of their target dates exceeds 19-Jan-2038,assuming a time_t is used to store them.

    Good luck, and hope no ones flying car breaks down in 2038
     
  2. badri

    badri New Member

    Joined:
    Jul 12, 2005
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    For those interested, test result of 2038.pl:
    ----------------------Solaris-5.8
    Tue Jan 19 03:14:01 2038
    Tue Jan 19 03:14:02 2038
    Tue Jan 19 03:14:03 2038
    Tue Jan 19 03:14:04 2038
    Tue Jan 19 03:14:05 2038
    Tue Jan 19 03:14:06 2038
    Tue Jan 19 03:14:07 2038
    Tue Jan 19 03:14:07 2038<<<<<<<<<<<<
    Tue Jan 19 03:14:07 2038
    Tue Jan 19 03:14:07 2038
    ----------------------Linux 2.6.12
    Tue Jan 19 03:14:01 2038
    Tue Jan 19 03:14:02 2038
    Tue Jan 19 03:14:03 2038
    Tue Jan 19 03:14:04 2038
    Tue Jan 19 03:14:05 2038
    Tue Jan 19 03:14:06 2038
    Tue Jan 19 03:14:07 2038
    Fri Dec 13 20:45:52 1901<<<<<<<<<<<<
    Fri Dec 13 20:45:52 1901
    Fri Dec 13 20:45:52 1901
    ----------------------Windows-XP :cool:
    Tue Jan 19 03:14:01 2038
    Tue Jan 19 03:14:02 2038
    Tue Jan 19 03:14:03 2038
    Tue Jan 19 03:14:04 2038
    Tue Jan 19 03:14:05 2038
    Tue Jan 19 03:14:06 2038
    Tue Jan 19 03:14:07 2038
    ..then it stops!!!

    1$ Q. will the Windos system stop running
    I leave this test to readers
    -----------------------

    Q1: What happens, someone who gets hist first pension, 1 second after
    Tue Jan 19 03:14:07 2038

    Q2: Air traffic control, all schedules change to?

    Q3: Alram clocks/watch don't work, so people get to work?
    ....
     
  3. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Welcome to the wonderful community of programmers.

    Also nice results on different OS.
     
  4. milind

    milind New Member

    Joined:
    Apr 21, 2006
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    ----------------------Solaris-5.8
    Tue Jan 19 03:14:01 2038
    Tue Jan 19 03:14:02 2038
    Tue Jan 19 03:14:03 2038
    Tue Jan 19 03:14:04 2038
    Tue Jan 19 03:14:05 2038
    Tue Jan 19 03:14:06 2038
    Tue Jan 19 03:14:07 2038
    Tue Jan 19 03:14:07 2038<<<<<<<<<<<<
    Tue Jan 19 03:14:07 2038<<<<<<<<<<<<
    Tue Jan 19 03:14:07 2038<<<<<<<<<<<<

    For the above result even though the time is neither year 1901 nor stopped as in windows, the count is stopped and the date-time is seized to Tue Jan 19 03:14:07 2038 only.

    Any logical reasoning....
     
  5. coderzone

    coderzone Super Moderator

    Joined:
    Jul 25, 2004
    Messages:
    736
    Likes Received:
    38
    Trophy Points:
    28
    The reason is probably what is given in post #1
     
  6. kash

    kash New Member

    Joined:
    Oct 13, 2006
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    0
    hey guys i did not understand the time_t concept.will the value for time _t be set when we install the window in our comp ....or it by default starts from 1/01/1970.
    what have we got to do with the year 1970 and the value of the variable time_t.
    can any one explain this to me.........
     
  7. Vromoth

    Vromoth New Member

    Joined:
    Nov 6, 2006
    Messages:
    43
    Likes Received:
    0
    Trophy Points:
    0
    Home Page:
    http://vromoth.4000webs.com/
    Then why would people make a computer that says it can go to 2099(mine) when it is going to crash at 2038?
     
  8. pradeep

    pradeep Team Leader

    Joined:
    Apr 4, 2005
    Messages:
    1,645
    Likes Received:
    87
    Trophy Points:
    0
    Occupation:
    Programmer
    Location:
    Kolkata, India
    Home Page:
    http://blog.pradeep.net.in
    Well with the current architechture i.e. 32-bit, computers won't be able to count beyond 2 147 483 647. Don't worry buy 2038 we won't be using 32-bit computers, we all will have switched over to 64-bit or may be something higher than that.;)
     
  9. kash

    kash New Member

    Joined:
    Oct 13, 2006
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    0
    wat have we got to do wit year 1970

    y u have mention the year 1970.......and wat have u got to do with the value of time_t and year 1970.
     
  10. pradeep

    pradeep Team Leader

    Joined:
    Apr 4, 2005
    Messages:
    1,645
    Likes Received:
    87
    Trophy Points:
    0
    Occupation:
    Programmer
    Location:
    Kolkata, India
    Home Page:
    http://blog.pradeep.net.in
    time systems count the time elasped in seconds, since January 1, 1970 at 12:00 AM Greenwich Mean Time, thats why.
     
  11. Vromoth

    Vromoth New Member

    Joined:
    Nov 6, 2006
    Messages:
    43
    Likes Received:
    0
    Trophy Points:
    0
    Home Page:
    http://vromoth.4000webs.com/
    Sorry about being a bit of a n00b, but my computer starts at 1980 not 1970 so will I get ten more years?
     
  12. Tutsuo

    Tutsuo New Member

    Joined:
    Jul 25, 2007
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    LOL HAHAAHAHAH


    ok ... anyways is this something you found ur self or u read somewhere? and are the different OSs makeing a patch ?
     
  13. Tutsuo

    Tutsuo New Member

    Joined:
    Jul 25, 2007
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    another thing i realized we wont have these same computers in 2038 and im sure by then we'll have better comps.
     
  14. hanleyhansen

    hanleyhansen New Member

    Joined:
    Jan 24, 2008
    Messages:
    336
    Likes Received:
    8
    Trophy Points:
    0
    Occupation:
    Drupal Developer/LAMP Developer
    Location:
    Clifton
    Home Page:
    http://www.hanseninfotech.com
    Well no matter how advanced our systems get we will always have a problem in the furture. But that is the great thing about the IT and Computer Science fields there's always work or planning to be done!!!
     
  15. swaerrt

    swaerrt New Member

    Joined:
    Feb 15, 2008
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    2038 is too far. That problem will solved too before. Do you people will use 32 bit machine on that time also.
     
  16. betty_krocker

    betty_krocker New Member

    Joined:
    Apr 14, 2008
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Yes but that would mean that EVERY or almost every network system in the world would have to be overhauled. Yes no doubt some newer things will be on 64-bit, but I can guarantee that some systems will still be one the old 32 bit system...

    Also I have found this works as a nasty trick to do on people you don't like, since Windows doesn't like the year 2038...
     
  17. SpOonWiZaRd

    SpOonWiZaRd Know what you can do.

    Joined:
    May 30, 2007
    Messages:
    746
    Likes Received:
    8
    Trophy Points:
    0
    Occupation:
    Network Engineer/Programmer
    Location:
    South Africa
    Who knows for sure what computer systems there will be, there can be 128bit system out by that time for all we know. Maybe a fix to reset the counter of time_t. Anything will be done to fix a major problem like this.
     
  18. seangtz

    seangtz New Member

    Joined:
    Jun 6, 2008
    Messages:
    126
    Likes Received:
    3
    Trophy Points:
    0
    Thanks for sharing valuable information...
     
  19. ownedattitude

    ownedattitude New Member

    Joined:
    Oct 7, 2008
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
  20. Storm_Rider

    Storm_Rider New Member

    Joined:
    Oct 23, 2008
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    0
    if you figured this out THATS COOL!!!!!!!!
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice