Sunday, February 03, 2013

The Year 2038 Problem



The year 2038 problem may cause some computer software to fail at some point near the year 2038. The problem affects all software and systems that both store system time as a signed 32-bit integer, and interpret this number as the number of seconds since 00:00:00 UTC on Thursday, 1 January 1970. The furthest time that can be represented this way is 03:14:07 UTC on Tuesday, 19 January 2038. Times beyond this moment will "wrap around" and be stored internally as a negative number, which these systems will interpret as a date in 1901 rather than 2038. This is caused by integer overflow. The counter "runs out" of usable digits, "increments" the sign bit instead, and reports a maximally negative number (continuing to count up, toward zero). This is likely to cause problems for users of these systems due to erroneous calculations.

Further, while most programs will only be affected in or very close to 2038, programs that work with future dates will begin to run into problems much sooner. For example, a program that works with dates 20 years in the future will have to be fixed no later than 2018.

Because most 32-bit Unix-like systems store and manipulate time in this format, it is usually called Unix time, and so the year 2038 problem is often referred to as the Unix Millennium Bug, or s2G.

In May 2006, reports surfaced of an early manifestation of the Y2038 problem in the AOLserver software. The software was designed with a kludge to handle a database request that should "never" time out. Rather than specifically handling this special case, the initial design simply specified an arbitrary time-out date in the future. The default configuration for the server specified that the request should time out after one billion seconds. One billion seconds (approximately thirty-two years) after 9:27.28 pm on 12 May 2006 is beyond the 2038 cutoff date. Thus, after this time, the time-out calculation overflowed and returned a date that was actually in the past, causing the software to crash. When the problem was discovered, AOL server managers had to edit the configuration file and set the time-out to a lower value.

Vulnerable Systems:
Embedded systems that use dates for either computation or diagnostic logging are most likely to be affected by the 2038 bug. Telecommunication systems and transportation systems from flight to automobiles increasingly use embedded systems. Automobiles, electric vehicles, and hybrid vehicles are increasingly using embedded systems to maximize efficiency and reduce pollution. Other automotive safety systems include anti-lock braking system (ABS), electronic stability control (ESC/ESP), traction control (TCS) and automatic four-wheel drive. New aircraft contain advanced avionics such as inertial guidance systems and GPS receivers that also have considerable safety requirements. Another major use of embedded systems is in communications devices, including cell phones and Internet appliances (routers, wireless access points, etc.) which rely on storing an accurate time and date and are increasingly based on UNIX-like operating systems. For example, the bug makes some Android devices crash and not restart when the time is changed to that date.

As of 2012, most embedded systems use 8-bit or 16-bit microprocessors, even as desktop systems are transitioning to 64-bit systems. Despite the modern 18–24-month generational update in computer systems technology, embedded systems are designed to last the lifetime of the machine in which they are a component. It is conceivable that some of these systems may still be in use in 2038. It may be impractical or, in some cases, impossible to upgrade the software running these systems, ultimately requiring replacement if 32-bit time_t limitations are to be corrected.

The use of 32-bit time_t has also been encoded into some file formats,[citation needed] which means it can live on well beyond the life of the machines on which such file formats were originally supported.

MySQL database's inbuilt functions like UNIX_TIMESTAMP() will return 0 after 03:14:07 UTC on 19 January 2038. The limit reached will vary in time, based on the time zones as in the following table:
Auckland19 January 2038, 16:14:07 NZDT (UTC+13:00)
Sydney19 January 2038, 14:14:07 AEDT (UTC+11:00)
Tokyo19 January 2038, 12:14:07 JST (UTC+09:00)
Beijing19 January 2038, 11:14:07 CST (UTC+08:00)
Mumbai19 January 2038, 08:44:07 IST (UTC+05:30)
Dubai19 January 2038, 07:14:07 GST (UTC+04:00)
Nairobi19 January 2038, 06:14:07 EAT (UTC+03:00)
Cairo19 January 2038, 05:14:07 EET (UTC+02:00)
Paris19 January 2038, 04:14:07 CET (UTC+01:00)
London19 January 2038, 03:14:07 GMT (UTC±00:00)
Brasília19 January 2038, 01:14:07 BRST (UTC−02:00)
Atlantic Time18 January 2038, 23:14:07 AST (UTC−04:00)
Eastern Time18 January 2038, 22:14:07 EST (UTC−05:00)
Central Time18 January 2038, 21:14:07 CST (UTC−06:00)
Mountain Time18 January 2038, 20:14:07 MST (UTC−07:00)
Pacific Time18 January 2038, 19:14:07 PST (UTC−08:00)
Hawaiʻi18 January 2038, 17:14:07 HST (UTC−10:00)
Data Structures With Time Problems:


Many data structures in use today have 32-bit time representations embedded into their structure. A full list of these data structures is virtually impossible to derive but there are well-known data structures that have the Unix time problem.

  • file systems (many filesystems use only 32 bits to represent times in inode)
  • binary file formats (that use 32-bit time fields)
  • databases (that have 32-bit time fields)
  • COBOL systems from the 1970s, 1980s and 1990s that have not been replaced by 2038-compliant systems
  • embedded factory, refinery control and monitoring subsystems
  • assorted medical devices
  • assorted military devices
Each one of these places where data structures using 32-bit time are in place has its own risks related to failure of the product to perform as designed.

Solutions:
There is no universal solution for the Year 2038 problem. Any change to the definition of the time_t data type would result in code compatibility problems in any application in which date and time representations are dependent on the nature of the signed 32-bit time_t integer. For example, changing time_t to an unsigned 32-bit integer, which would extend the range to the year 2106, would adversely affect programs that store, retrieve, or manipulate dates prior to 1970, as such dates are represented by negative numbers.

Most operating systems designed to run on 64-bit hardware already use signed 64-bit time_t integers, effectively eliminating the Year 2038 problem in any software that has been developed to use the extended format. Using a signed 64-bit value introduces a new wraparound date that is over twenty times greater than the estimated age of the universe: approximately 292 billion years from now, at 15:30:08 on Sunday, 4 December 292,277,026,596. The ability to make computations on dates is limited by the fact that tm_year uses a signed 32 bit int value starting at 1900 for the year. This limits the year to a maximum of 2,147,485,547 (2,147,483,647 + 1900).[7] While this solves the problem for executing programs, it does not, however, solve the problem of storing date values within binary data files, many of which employ rigid storage formats.

Starting with NetBSD version 6.0 (released in October 2012), the NetBSD operating system uses a 64-bit time_t for both 32-bit and 64-bit architectures. Applications that were compiled for an older NetBSD release with 32-bit time_t are supported via a binary compatibility layer, but such older applications will still suffer from the Year 2038 problem.

Alternative proposals have been made (some of which are in use), such as storing either milliseconds or microseconds since an epoch (typically either 1 January 1970 or 1 January 2000) in a signed 64-bit integer, providing a minimum of 300,000 years range.[8][9] Other proposals for new time representations provide different precisions, ranges, and sizes (almost always wider than 32 bits), as well as solving other related problems, such as the handling of leap seconds. In particular, TAI64[10] is an implementation of the Temps Atomique International standard, the current international real-time standard for defining a second and frame of reference.

No comments: