Year 2038 problem explained

The year 2038 problem (also known as Y2038, Y2K38, Y2K38 superbug or the Epochalypse[1] [2]) is a time computing problem that leaves some computer systems unable to represent times after 03:14:07 UTC on 19 January 2038.

The problem exists in systems which measure Unix time - the number of seconds elapsed since the Unix epoch (00:00:00 UTC on 1 January 1970) - and store it in a signed 32-bit integer. The data type is only capable of representing integers between -(2) and 231 - 1, meaning the latest time that can be properly encoded is 2 - 1 seconds after epoch (03:14:07 UTC on 19 January 2038). Attempting to increment to the following second (03:14:08) will cause the integer to overflow, setting its value to -(2) which systems will interpret as 2 seconds before epoch (20:45:52 UTC on 13 December 1901). The problem is similar in nature to the year 2000 problem, the difference being the Year 2000 problem had to do with base 10 numbers, whereas the Year 2038 problem involves base 2 numbers.

Analogous storage constraints will be reached in 2106, where systems storing Unix time as an unsigned (rather than signed) 32-bit integer will overflow on 7 February 2106 at 06:28:15 UTC.

Computer systems that use time for critical computations may encounter fatal errors if the year 2038 problem is not addressed. Some applications that use future dates have already encountered the bug. The most vulnerable systems are those which are infrequently or never updated, such as legacy and embedded systems. Modern systems and software updates to legacy systems address this problem by using signed 64-bit integers instead of 32-bit integers, which will take 292 billion years to overflow—approximately 21 times the estimated age of the universe.

Cause

Many computer systems measure time and date using Unix time, an international standard for digital timekeeping. Unix time is defined as the number of seconds elapsed since 00:00:00 UTC on 1 January 1970 (an arbitrarily chosen time based on the creation of the first Unix system), which has been dubbed the Unix epoch.[3]

Unix time has historically been encoded as a signed 32-bit integer, a data type composed of 32 binary digits (bits) which represent an integer value, with 'signed' meaning that the number can represent both positive and negative numbers, as well as zero; and is usually stored in two's complement format. Thus, a signed 32-bit integer can only represent integer values from -(2) to 231 - 1 inclusive. Consequently, if a signed 32-bit integer is used to store Unix time, the latest time that can be stored is 231 - 1 (2,147,483,647) seconds after epoch, which is .[4] Systems that attempt to increment this value by one more second to 2 seconds after epoch (03:14:08) will suffer integer overflow, inadvertently flipping the sign bit to indicate a negative number. This changes the integer value to -(2), or 2 seconds before epoch rather than after, which systems will interpret as 20:45:52 on Friday, 13 December 1901. From here, systems will continue to count up, toward zero, and then up through the positive integers again. As many computer systems use time computations to run critical functions, the bug may introduce serious problems.

Vulnerable systems

Any system using data structures with signed 32-bit time representations has an inherent risk of failing. 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:

Embedded systems

Embedded systems that use dates for either computation or diagnostic logging are most likely to be affected by the Y2038 problem.[5] 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 the 32-bit limitations are to be corrected.

Many transportation systems from flight to automobiles use embedded systems extensively. In automotive systems, this may include anti-lock braking system (ABS), electronic stability control (ESC/ESP), traction control (TCS) and automatic four-wheel drive; aircraft may use inertial guidance systems and GPS receivers. Another major use of embedded systems is in communications devices, including cell phones and Internet-enabled appliances (e.g. routers, wireless access points, IP cameras) which rely on storing an accurate time and date and are increasingly based on Unix-like operating systems. For example, the Y2038 problem makes some devices running 32-bit Android crash and not restart when the time is changed to that date.[6]

However, this does not imply that all embedded systems will suffer from the Y2038 problem, since many such systems do not require access to dates. For those that do, those systems which only track the difference between times/dates and not absolute times/dates will, by the nature of the calculation, not experience a major problem. This is the case for automotive diagnostics based on legislated standards such as CARB (California Air Resources Board).[7]

Early problems

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 with a default configuration specifying that requests should time out after a maximum of one billion seconds. However, one billion seconds before the 2038 cutoff date is 01:27:28 UTC on 13 May 2006, so requests sent after this time would result in a time-out date which is beyond the cutoff. This made time-out calculations overflow and return dates that were actually in the past, causing software to crash. When the problem was discovered, AOLServer operators had to edit the configuration file and set the time-out to a lower value.[8] [9]

Solutions

There is no universal solution for the Year 2038 problem. For example, in the C language, 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 2106[10] (specifically, 06:28:15 UTC on Sunday, 7 February 2106), would adversely affect programs that store, retrieve, or manipulate dates prior to 1970, as such dates are represented by negative numbers. Increasing the size of the time_t type to 64 bits in an existing system would cause incompatible changes to the layout of structures and the binary interface of functions.

Most operating systems designed to run on 64-bit hardware already use signed 64-bit time_t integers. 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.[11] The ability to make computations on dates is limited by the fact that tm_year uses a signed 32-bit integer value starting at 1900 for the year. This limits the year to a maximum of 2,147,485,547 (2,147,483,647 + 1900).[12]

Alternative proposals have been made (some of which are already 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 range of 300,000 years at microsecond resolution.[13] [14] In particular, Java's use of 64-bit long integers everywhere to represent time as "milliseconds since 1 January 1970" will work correctly for the next 292 million years. 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[15] is an implementation of the International Atomic Time (TAI) standard, the current international real-time standard for defining a second and frame of reference.

Implemented solutions

See also

External links

Notes and References

  1. Web site: The end of an Era . February 6, 2020 . Arnd . Bergmann . Linaro . 13 September 2020 . 7 February 2020 . https://web.archive.org/web/20200207034639/https://www.linaro.org/blog/the-end-of-an-era/ . live .
  2. News: Digital 'Epochalypse' Could Bring World to Grinding Halt . Paul . Wagenseil . July 28, 2017 . Tom's Guide . 13 September 2020 . 29 November 2021 . https://web.archive.org/web/20211129222317/https://www.tomsguide.com/us/2038-bug-bh2017,news-25551.html . live .
  3. Web site: Epoch Time. 13 April 2023. unixtutoria. 15 March 2019. en. 13 April 2023. https://web.archive.org/web/20230413221727/https://www.unixtutorial.org/epoch-time/. live.
  4. Book: Diomidis Spinellis. Code quality: the open source perspective. Adobe Press. 2006. 978-0-321-16607-4. illustrated. Effective software development series in Safari Books Online. 49.
  5. News: Is the Year 2038 problem the new Y2K bug?. The Guardian. 17 December 2014. 11 October 2018. 25 January 2022. https://web.archive.org/web/20220125075051/https://www.theguardian.com/technology/2014/dec/17/is-the-year-2038-problem-the-new-y2k-bug. live.
  6. Web site: ZTE Blade running Android 2.2 has 2038 problems. 20 November 2018. 19 May 2022. https://web.archive.org/web/20220519230355/https://issuetracker.google.com/issues/36928638. live.
  7. Web site: ARB Test Methods / Procedures. California Air Resources Board. ARB.ca.gov. 12 September 2013. 18 November 2016. https://web.archive.org/web/20161118163253/https://www.arb.ca.gov/testmeth/testmeth.htm#vehicles. dead.
  8. Web site: 28 June 2006. The Future Lies Ahead. 19 November 2006. 28 November 2006. https://web.archive.org/web/20061128235428/http://substitute.livejournal.com/1430908.html. live.
  9. http://www.mail-archive.com/aolserver@listserv.aol.com/msg09844.html Weird "memory leak" problem in AOLserver 3.4.2/3.x
  10. Web site: DRAFT: Y2038 Proofness Design . 2024-05-25 . 21 September 2019 . https://web.archive.org/web/20190921231248/https://sourceware.org/glibc/wiki/Y2038ProofnessDesign . live .
  11. Web site: When does the 64-bit Unix time_t really end? . 2022-09-24 . 23 September 2022 . https://web.archive.org/web/20220923220457/https://ximalas.info/2015/03/10/when-does-the-64-bit-unix-time_t-really-end/ . live .
  12. Web site: The End of Time. 17 April 2010. 19 March 2012. Bob. Felts. Stablecross.com. 11 October 2012. https://web.archive.org/web/20121011060328/http://stablecross.com/files/End_Of_Time.html. live.
  13. Web site: Unununium Time. https://web.archive.org/web/20060408161959/http://unununium.org/articles/uuutime. 8 April 2006 . 19 November 2006.
  14. Web site: Java API documentation for System.currentTimeMillis. Sun Microsystems. 29 September 2017. 30 September 2017. https://web.archive.org/web/20170930040244/https://docs.oracle.com/javase/9/docs/api/java/lang/System.html#currentTimeMillis--. live.
  15. Web site: TAI64. 4 September 2012. 26 September 2012. https://web.archive.org/web/20120926120001/http://cr.yp.to/libtai/tai64.html. live.
  16. Web site: 18 August 2010. Ruby 1.9.2 is released. 1 April 2022. 8 April 2022. https://web.archive.org/web/20220408110503/https://www.ruby-lang.org/en/news/2010/08/18/ruby-1-9-2-released/. live.
  17. Web site: time.c: use 64bit arithmetic even on platforms with 32bit VALUE . . 3 November 2023 . 3 November 2023 . https://web.archive.org/web/20231103040211/https://github.com/ruby/ruby/commit/cea57f8fff58d933cd7a452e9ee0745d5a7c7577 . live .
  18. Web site: 17 October 2012. Announcing NetBSD 6.0. 18 January 2016. 15 January 2016. https://web.archive.org/web/20160115091208/http://www.netbsd.org/releases/formal-6/NetBSD-6.0.html. live.
  19. Web site: 1 May 2014. OpenBSD 5.5 released (May 1, 2014). 18 January 2016. 22 December 2015. https://web.archive.org/web/20151222005608/http://www.openbsd.org/plus55.html. live.
  20. Web site: Jonathan Corbet. Jonathan Corbet. 14 August 2013. Pondering 2038. live. https://web.archive.org/web/20160304081847/https://lwn.net/Articles/563285/. 4 March 2016. 9 March 2016. LWN.net.
  21. Web site: LKML: Arnd Bergmann: [GIT PULL] y2038: core, driver and file system changes]. 2020-01-30. lkml.org. 14 February 2020. https://web.archive.org/web/20200214070752/https://lkml.org/lkml/2020/1/29/355?anz=web. live.
  22. Web site: O'Donell . Carlos . The GNU C Library version 2.34 is now available . Sourceware . 2024-04-30 . 2021-08-02 . 30 April 2024 . https://web.archive.org/web/20240430060406/https://sourceware.org/pipermail/libc-alpha/2021-August/129718.html . live .
  23. Web site: arch. www.freebsd.org. 26 September 2018. 26 September 2018. https://web.archive.org/web/20180926205510/https://www.freebsd.org/cgi/man.cgi?arch. live.
  24. 7530. Network File System (NFS) Version 4 Protocol. 2.2. Structured Data Types. March 2015. Thomas. Haynes. David. Noveck.
  25. Web site: NFS Version 3 Protocol Specification . June 1995 . 2024-05-25 . Staubach . Peter . Pawlowski . Brian . Callaghan . Brent .
  26. Web site: ext4 Data Structures and Algorithms. 2022-09-13. 13 September 2022. https://web.archive.org/web/20220913224855/https://www.kernel.org/doc/html/latest/filesystems/ext4/dynamic.html#inode-timestamps. live.
  27. Web site: XFS File-System With Linux 5.10 Punts Year 2038 Problem To The Year 2486. Michael Larabel. Phoronix. 15 October 2020. 2022-09-13. 13 September 2022. https://web.archive.org/web/20220913232215/https://www.phoronix.com/news/XFS-Linux-5.10. live.
  28. Web site: 1997-07-24. Why is Wednesday, November 17, 1858 the base time for OpenVMS (VAX VMS)?. live. https://web.archive.org/web/19970724202734/https://www.slac.stanford.edu/~rkj/crazytime.txt. 1997-07-24. 2020-01-08. Stanford University. dmy-all.
  29. Web site: November 2020. VSI C Run-Time Library Reference Manual for OpenVMS Systems. 2021-04-17. VSI. 17 April 2021. https://web.archive.org/web/20210417113107/https://vmssoftware.com/docs/VSI_CRTL_REF.pdf. dead.
  30. Web site: OpenVMS and the year 2038. 2021-04-17. HP. 17 April 2021. https://web.archive.org/web/20210417113108/https://www.zx.net.nz/mirror/h71000.www7.hp.com/2038.html. live.
  31. Web site: PostgreSQL Release 7.2. January 2012. 25 April 2024. 26 April 2024. https://web.archive.org/web/20240426022618/https://www.postgresql.org/docs/7.2/release-7-2.html. live.
  32. Web site: What Is New in MySQL 8.0. dev.mysql.com.
  33. Web site: Changes in MySQL 8.0.28 (2022-01-18, General Availability). dev.mysql.com. 14 May 2024. 8 December 2023. https://web.archive.org/web/20231208180456/https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-28.html. live.
  34. Web site: MySQL Bugs: #12654: 64-bit unix timestamp is not supported in MySQL functions. bugs.mysql.com. 28 March 2017. 29 March 2017. https://web.archive.org/web/20170329045924/https://bugs.mysql.com/bug.php?id=12654. live.
  35. Web site: 2023-05-25 . Microsoft C/C++ change history 2003 - 2015 . 2024-08-13 . learn.microsoft.com . en-us.
  36. Web site: 2021-01-07 . About Time - Win32 apps . 2024-08-13 . learn.microsoft.com . en-us.