Revision as of 09:21, 13 December 2006 editNotinasnaid (talk | contribs)13,255 edits No obviously new content in external link← Previous edit | Latest revision as of 19:17, 25 December 2024 edit undoSynorem (talk | contribs)Extended confirmed users, Pending changes reviewers, Rollbackers7,834 edits Unnecessary | ||
Line 1: | Line 1: | ||
{{short description|Computer software bug occurring in 2038}} | |||
The '''year 2038 problem''' may cause some ] to fail before or in the year 2038. The problem affects programs that use the ] representation, which represents ] as the number of seconds (ignoring ]s) since ], ]. This representation is standard in ]-like operating systems and also affects software written for most other operating systems because of the broad deployment of ]. On most 32-bit systems, the <code>]</code> data type used to store this second count is a ] ] ]. The latest time that can be represented in this format, following the POSIX standard, is 03:14:07 ] on Tuesday, ], ]. Times beyond this moment will "wrap around" and be represented internally as a negative number, and cause programs to fail, since they will see these times not as being in 2038 but rather in 1970 or 1901, depending on the implementation. Erroneous calculations and decisions may therefore result. | |||
] error will occur at 03:14:08 UTC on 19 January 2038.]] | |||
The '''year 2038 problem''' (also known as '''Y2038''',<ref name=":0" /> '''Y2K38''', '''Y2K38 superbug''' or the '''Epochalypse'''<ref>{{cite web |url=https://www.linaro.org/blog/the-end-of-an-era/ |title=The end of an Era |date=February 6, 2020 |first=Arnd |last=Bergmann |publisher=Linaro |access-date=13 September 2020 |archive-date=7 February 2020 |archive-url=https://web.archive.org/web/20200207034639/https://www.linaro.org/blog/the-end-of-an-era/ |url-status=live }}</ref><ref>{{cite news |url=https://www.tomsguide.com/us/2038-bug-bh2017,news-25551.html |title=Digital 'Epochalypse' Could Bring World to Grinding Halt |first=Paul |last=Wagenseil |date=July 28, 2017 |work=Tom's Guide |access-date=13 September 2020 |archive-date=29 November 2021 |archive-url=https://web.archive.org/web/20211129222317/https://www.tomsguide.com/us/2038-bug-bh2017,news-25551.html |url-status=live }}</ref>) is a ] that leaves some computer systems unable to represent times after 03:14:07 ] on 19 January 2038. | |||
The problem exists in systems which measure ]—the number of seconds elapsed since the ''Unix ]'' (00:00:00 UTC on 1 January 1970)—and store it in a ]. The data type is only capable of representing integers between −(2{{sup|31}}) and ], meaning the latest time that can be properly encoded is 2{{sup|31}} − 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 ], setting its value to −(2{{sup|31}}) which systems will interpret as 2{{sup|31}} seconds ''before'' epoch (20:45:52 UTC on 13 December 1901). The problem is similar in nature to the ], the difference being the Year 2000 problem had to do with ], whereas the Year 2038 problem involves ]. | |||
"Year 2038" is frequently abbreviated to "Y2038" or sometimes "Y2K38" in software professionals' jargon. | |||
Analogous storage constraints will be reached in ], 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. | |||
==Known problems== | |||
In May 2006, reports surfaced of an early Y2038 problem in the ] software. The software would specify that a database request should "never" timeout by specifying a timeout date one billion seconds in the future. One billion seconds after 21:27:28 on ] ] is beyond the 2038 cutoff date, so after this date, the timeout calculation overflowed and calculated a timeout date that was actually in the past, causing the software to crash.<ref>{{cite web | url=http://substitute.livejournal.com/1430908.html | title=The Future Lies Ahead | date=] | accessdate=2006-11-19}}</ref><ref>{{cite web | url=http://www.mail-archive.com/aolserver@listserv.aol.com/msg09812.html | title=Something wrong after 2006-05-12 21:25 | first=Dossy | last=Shiobara | date=] | accessdate=2006-11-19}}</ref> | |||
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.<ref name=":1" /><ref name=":2" /> The most vulnerable systems are those which are infrequently or never updated, such as ] and ]s. Modern systems and software updates to legacy systems address this problem by using signed ] integers instead of 32-bit integers, which will take 292 billion years to overflow—approximately 21 times the estimated ]. | |||
==Solutions== | |||
There is no easy fix for this problem for existing ]/] combinations. Changing the definition of <code>time_t</code> to use a 64-bit type would break binary compatibility for software, data storage, and generally anything dealing with the binary representation of time. Changing <code>time_t</code> to an unsigned 32-bit integer, effectively allowing timestamps to be accurate until the year 2106, would affect many programs that deal with time differences. | |||
== Cause == | |||
Most operating systems for ] ]s already use 64-bit integers in their <code>time_t</code>. The move to these architectures is already underway and many expect it to be complete before 2038. However, as of 2006, hundreds of millions of 32-bit systems are deployed, many in ]s, and it is far from certain they will all be replaced by 2038. Despite the modern 18- to 24-month generational update in computer systems technology, embedded computers may operate unchanged for the life of the system they control. The use of 32-bit <code>time_t</code> has also been encoded into file formats, such as the common ], which means it can live on for a long time beyond the life of the machines involved. | |||
Many computer systems measure time and date using ], an international standard for digital timekeeping. Unix time is defined as the number of seconds elapsed since 00:00:00 ] on 1 January 1970 (an arbitrarily chosen time based on the creation of the first ]), which has been dubbed the ''Unix epoch''.<ref name="CNMP-H-78-KY-M-Leviticus25:35-37 ">{{cite web|title=Epoch Time|url=https://www.unixtutorial.org/epoch-time/|access-date=13 April 2023|work=unixtutoria|date=15 March 2019|language=en|archive-date=13 April 2023|archive-url=https://web.archive.org/web/20230413221727/https://www.unixtutorial.org/epoch-time/|url-status=live}}</ref> | |||
Unix time has historically been encoded as a ], a data type composed of 32 ] (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 ] format.{{efn|Unless otherwise specified, all the numbers provided in this article have been derived using two's complement for signed integer arithmetic.}} Thus, a signed 32-bit integer can only represent integer values from −(2{{sup|31}}) to ] inclusive. Consequently, if a signed 32-bit integer is used to store Unix time, the latest time that can be stored is 2<sup>31</sup> − 1 (2,147,483,647) seconds after epoch, which is {{#time:H:i:s "on" l, j F Y|@{{#expr:2^31 -1}}}}.<ref name="spinellis">{{cite book|author=Diomidis Spinellis|url=https://books.google.com/books?id=vEN-ckcdtCwC&q=292%2C277%2C026%2C596&pg=PA49|title=Code quality: the open source perspective|publisher=]|year=2006|isbn=978-0-321-16607-4|edition=illustrated|series=Effective software development series in ]|page=49}}</ref> Systems that attempt to increment this value by one more second to 2{{sup|31}} seconds after epoch (03:14:08) will suffer ], inadvertently flipping the sign bit to indicate a negative number. This changes the integer value to −(2{{sup|31}}), or 2{{sup|31}} 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. | |||
Using a (signed) 64-bit value introduces a new wraparound date in about 290 billion years, on Sunday, December 4, ]. However, this problem is not widely regarded as a pressing issue. (A signed, 64-bit value is used in Microsoft's proposed replacement for time_t, dubbed __time64_t.) | |||
== Vulnerable systems == | |||
A proposal by the ] project is to count the number of ]s since midnight, ], ] ] in a signed 64 bit integer, which would be enough for the next 300,000 years in microsecond resolution.<ref>{{cite web | url=http://www.unununium.org/articles/uuutime | title=Unununium Time | accessdate=2006-11-19}}</ref> | |||
Any system using ]s 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: | |||
* File systems that use 32 bits to represent times in ]s | |||
* Databases with 32-bit time fields | |||
* Database query languages (such as ]) that have <code>UNIX_TIMESTAMP()</code>-like commands | |||
=== Embedded systems === | |||
==References== | |||
]s that use dates for either computation or diagnostic logging are most likely to be affected by the Y2038 problem.<ref name=":0">{{cite news|url=https://www.theguardian.com/technology/2014/dec/17/is-the-year-2038-problem-the-new-y2k-bug|title=Is the Year 2038 problem the new Y2K bug?|newspaper=The Guardian|date=17 December 2014|access-date=11 October 2018|archive-date=25 January 2022|archive-url=https://web.archive.org/web/20220125075051/https://www.theguardian.com/technology/2014/dec/17/is-the-year-2038-problem-the-new-y2k-bug|url-status=live}}</ref> Despite the modern ], 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. | |||
<div class="references-small"><references/></div> | |||
Many transportation systems from flight to automobiles use embedded systems extensively. <!-- Please do not delete - for decades, there will be plenty of older cars on the road, which will use the same outdated 8/16 bit systems for decades, unless something changes. Actually it already has - engine controllers have been mostly 32-bit for a decade! But the point stands, that legacy systems can't easily be changed. --> In automotive systems, this may include ] (ABS), ] (ESC/ESP), ] (TCS) and automatic ]; aircraft may use ] and ].{{efn|GPS suffers its own time counter overflow problem known as ].}} Another major use of embedded systems is in communications devices, including cell phones and Internet-enabled appliances (e.g. ], ]s, ]s) 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 ] crash and not restart when the time is changed to that date.<ref>{{cite web|title=ZTE Blade running Android 2.2 has 2038 problems|url=https://issuetracker.google.com/issues/36928638|access-date=20 November 2018|archive-date=19 May 2022|archive-url=https://web.archive.org/web/20220519230355/https://issuetracker.google.com/issues/36928638|url-status=live}}</ref> | |||
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 (]).<ref>{{cite web|url=http://www.arb.ca.gov/testmeth/testmeth.htm#vehicles|title=ARB Test Methods / Procedures|publisher=]|website=ARB.ca.gov|access-date=12 September 2013|archive-date=18 November 2016|archive-url=https://web.archive.org/web/20161118163253/https://www.arb.ca.gov/testmeth/testmeth.htm#vehicles|url-status=dead}}</ref> | |||
== Early problems == | |||
In May 2006, reports surfaced of an early manifestation of the Y2038 problem in the ] software. The software was designed with a ] to handle a database request that should "never" time out. Rather than specifically handling this special case, the initial design simply specified an arbitrary ] 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.<ref name=":1">{{cite web|date=28 June 2006|title=The Future Lies Ahead|url=http://substitute.livejournal.com/1430908.html|access-date=19 November 2006|archive-date=28 November 2006|archive-url=https://web.archive.org/web/20061128235428/http://substitute.livejournal.com/1430908.html|url-status=live}}</ref><ref name=":2"> {{Webarchive|url=https://web.archive.org/web/20100104130626/http://www.mail-archive.com/aolserver@listserv.aol.com/msg09844.html |date=4 January 2010 }} 12 May 2006</ref> | |||
== Solutions<span class="anchor" id="Y2106"></span> == | |||
There is no universal solution for the Year 2038 problem. For example, in the ], any change to the definition of the <code>]</code> data type would result in ] problems in any application in which date and time representations are dependent on the nature of the signed 32-bit <code>time_t</code> integer. Changing <code>time_t</code> to an unsigned 32-bit integer, which would extend the range to 2106<ref>{{cite web | url = https://sourceware.org/glibc/Y2038ProofnessDesign | title = DRAFT: Y2038 Proofness Design | access-date = 2024-05-25 | archive-date = 21 September 2019 | archive-url = https://web.archive.org/web/20190921231248/https://sourceware.org/glibc/Y2038ProofnessDesign | url-status = live }}</ref> (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 <code>time_t</code> 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 ] already use signed 64-bit <code>time_t</code> integers. Using a signed 64-bit value introduces a new wraparound date that is over twenty times greater than the estimated ]: approximately 292 billion years from now.<ref>{{cite web | url = https://ximalas.info/2015/03/10/when-does-the-64-bit-unix-time_t-really-end/ | title = When does the 64-bit Unix time_t really end? | access-date = 2022-09-24 | archive-date = 23 September 2022 | archive-url = https://web.archive.org/web/20220923220457/https://ximalas.info/2015/03/10/when-does-the-64-bit-unix-time_t-really-end/ | url-status = live }}</ref> The ability to make ]s on dates is limited by the fact that <code>tm_year</code> 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).<ref>{{cite web|url=http://stablecross.com/files/End_Of_Time.html|date=17 April 2010|title=The End of Time|access-date=19 March 2012|first=Bob|last=Felts|website=Stablecross.com|archive-date=11 October 2012|archive-url=https://web.archive.org/web/20121011060328/http://stablecross.com/files/End_Of_Time.html|url-status=live}}</ref> | |||
Alternative proposals have been made (some of which are already in use), such as storing either ]s or ]s since an epoch (typically either 1 January 1970 or 1 January 2000) in a signed 64-bit integer, providing a minimum range of 292,000 years at microsecond resolution.<ref>{{cite web | |||
| url=http://unununium.org/articles/uuutime | |||
| archive-url=https://web.archive.org/web/20060408161959/http://unununium.org/articles/uuutime | |||
| archive-date=8 April 2006 |title=Unununium Time | |||
| access-date=19 November 2006}}</ref><ref>{{cite web | |||
| url=https://docs.oracle.com/javase/9/docs/api/java/lang/System.html#currentTimeMillis-- | |||
| title=Java API documentation for System.currentTimeMillis() | |||
| author=Sun Microsystems | |||
| access-date=29 September 2017 | |||
| archive-date=30 September 2017 | |||
| archive-url=https://web.archive.org/web/20170930040244/https://docs.oracle.com/javase/9/docs/api/java/lang/System.html#currentTimeMillis-- | |||
| url-status=live | |||
}}</ref> In particular, Java's and JavaScript's use of 64-bit signed integers to represent absolute timestamps as "milliseconds since 1 January 1970" will work correctly for the next {{tooltip|1=292 million years|2=The theoretical overflow date is 17 August 292278994, 07:12:55.807 UTC.}}. 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 ]s. In particular, TAI64<ref>{{Cite web|url=http://cr.yp.to/libtai/tai64.html|title=TAI64|access-date=4 September 2012|archive-date=26 September 2012|archive-url=https://web.archive.org/web/20120926120001/http://cr.yp.to/libtai/tai64.html|url-status=live}}</ref> is an implementation of the ] (TAI) standard, the current international real-time standard for defining a second and frame of reference. | |||
=== Implemented solutions === | |||
* Starting with ] version 1.9.2 (released on 18 August 2010), the bug with year 2038 is fixed,<ref>{{cite web|date=18 August 2010|title=Ruby 1.9.2 is released|url=https://www.ruby-lang.org/en/news/2010/08/18/ruby-1-9-2-released/|access-date=1 April 2022|archive-date=8 April 2022|archive-url=https://web.archive.org/web/20220408110503/https://www.ruby-lang.org/en/news/2010/08/18/ruby-1-9-2-released/|url-status=live}}</ref> by storing time in a signed 64-bit integer on systems with 32-bit <code>time_t</code>.<ref>{{Cite web |title=time.c: use 64bit arithmetic even on platforms with 32bit VALUE |website=] |url=https://github.com/ruby/ruby/commit/cea57f8fff58d933cd7a452e9ee0745d5a7c7577 |access-date=3 November 2023 |archive-date=3 November 2023 |archive-url=https://web.archive.org/web/20231103040211/https://github.com/ruby/ruby/commit/cea57f8fff58d933cd7a452e9ee0745d5a7c7577 |url-status=live }}</ref> | |||
* Starting with ] version 6.0 (released in October 2012), the NetBSD operating system uses a 64-bit <code>time_t</code> for both 32-bit and 64-bit architectures. Applications that were compiled for an older NetBSD release with 32-bit <code>time_t</code> are supported via a binary compatibility layer, but such older applications will still suffer from the Y2038 problem.<ref>{{cite web|date=17 October 2012|title=Announcing NetBSD 6.0|url=https://www.netbsd.org/releases/formal-6/NetBSD-6.0.html|access-date=18 January 2016|archive-date=15 January 2016|archive-url=https://web.archive.org/web/20160115091208/http://www.netbsd.org/releases/formal-6/NetBSD-6.0.html|url-status=live}}</ref> | |||
* ] since version 5.5, released in May 2014, also uses a 64-bit <code>time_t</code> for both 32-bit and 64-bit architectures. In contrast to ], there is no binary compatibility layer. Therefore, applications expecting a 32-bit <code>time_t</code> and applications using anything different from <code>time_t</code> to store time values may break.<ref>{{cite web|date=1 May 2014|title=OpenBSD 5.5 released (May 1, 2014)|url=http://www.openbsd.org/plus55.html|access-date=18 January 2016|archive-date=22 December 2015|archive-url=https://web.archive.org/web/20151222005608/http://www.openbsd.org/plus55.html|url-status=live}}</ref> | |||
* ] originally used a 64-bit <code>time_t</code> for 64-bit architectures only; the pure 32-bit ] was not changed due to backward compatibility.<ref name="Pondering2038">{{cite web|author=Jonathan Corbet|author-link=Jonathan Corbet|date=14 August 2013|title=Pondering 2038|url=https://lwn.net/Articles/563285/|url-status=live|archive-url=https://web.archive.org/web/20160304081847/https://lwn.net/Articles/563285/|archive-date=4 March 2016|access-date=9 March 2016|website=]}}</ref> Starting with version ] of 2020, 64-bit <code>time_t</code> is supported on 32-bit architectures, too. This was done primarily for the sake of ] systems.<ref>{{Cite web|title=LKML: Arnd Bergmann: y2038: core, driver and file system changes|url=https://lkml.org/lkml/2020/1/29/355?anz=web|access-date=2020-01-30|website=lkml.org|archive-date=14 February 2020|archive-url=https://web.archive.org/web/20200214070752/https://lkml.org/lkml/2020/1/29/355?anz=web|url-status=live}}</ref> | |||
* ] since version 2.34 (released August 2021), added support for using 64-bit <code>time_t</code> on 32-bit platforms with appropriate Linux versions. This support can be activated by defining preprocessor macro <code>_TIME_BITS</code> to <code>64</code> when compiling source code.<ref>{{cite web |last1=O'Donell |first1=Carlos |title=The GNU C Library version 2.34 is now available |url=https://sourceware.org/pipermail/libc-alpha/2021-August/129718.html |website=Sourceware |access-date=2024-04-30 |date=2021-08-02 |archive-date=30 April 2024 |archive-url=https://web.archive.org/web/20240430060406/https://sourceware.org/pipermail/libc-alpha/2021-August/129718.html |url-status=live }}</ref> | |||
* ] uses 64-bit <code>time_t</code> for all 32-bit and 64-bit architectures except 32-bit i386, which uses signed 32-bit <code>time_t</code> instead.<ref>{{Cite web|url=https://www.freebsd.org/cgi/man.cgi?arch|title=arch|website=www.freebsd.org|access-date=26 September 2018|archive-date=26 September 2018|archive-url=https://web.archive.org/web/20180926205510/https://www.freebsd.org/cgi/man.cgi?arch|url-status=live}}</ref> | |||
* The ] for Linux (which defines an environment for programs with 32-bit addresses but running the processor in 64-bit mode) uses a 64-bit <code>time_t</code>. Since it was a new environment, there was no need for special compatibility precautions.<ref name="Pondering2038" /> | |||
* ] version 4 has defined its time fields as <code>struct nfstime4 {int64_t seconds; uint32_t nseconds;}</code> since December 2000.<ref>{{cite IETF|rfc=7530|title=Network File System (NFS) Version 4 Protocol|section=2.2|sectionname=Structured Data Types|date=March 2015|editor1-first=Thomas|editor1-last=Haynes|editor2-first=David|editor2-last=Noveck}}</ref> Version 3 supports unsigned 32-bit values as <code>struct nfstime3 {uint32 seconds; uint32 nseconds;};</code>.<ref>{{cite web | url = https://datatracker.ietf.org/doc/html/rfc1813 | title= NFS Version 3 Protocol Specification | date= June 1995 | access-date = 2024-05-25 | last1= Staubach | first1= Peter | last2= Pawlowski | first2= Brian | last3= Callaghan | first3= Brent }}</ref> Values greater than zero for the seconds field denote dates after the 0-hour, January 1, 1970. Values less than zero for the seconds field denote dates before the 0-hour, January 1, 1970. In both cases, the nseconds (nanoseconds) field is to be added to the seconds field for the final time representation. | |||
* The ] filesystem, when used with inode sizes larger than 128 bytes, has an extra 32-bit field per timestamp, of which 30 bits are used for the nanoseconds part of the timestamp, and the other 2 bits are used to extend the timestamp range to the year 2446.<ref>{{cite web|url=https://www.kernel.org/doc/html/latest/filesystems/ext4/dynamic.html#inode-timestamps|title=ext4 Data Structures and Algorithms|access-date=2022-09-13|archive-date=13 September 2022|archive-url=https://web.archive.org/web/20220913224855/https://www.kernel.org/doc/html/latest/filesystems/ext4/dynamic.html#inode-timestamps|url-status=live}}</ref> | |||
* The ] filesystem, starting with Linux 5.10, has an optional "big timestamps" feature which extends the timestamp range to the year 2486.<ref>{{cite web|url=https://www.phoronix.com/news/XFS-Linux-5.10|title=XFS File-System With Linux 5.10 Punts Year 2038 Problem To The Year 2486|author=Michael Larabel|website=]|date=15 October 2020|access-date=2022-09-13|archive-date=13 September 2022|archive-url=https://web.archive.org/web/20220913232215/https://www.phoronix.com/news/XFS-Linux-5.10|url-status=live}}</ref> | |||
* While the native APIs of ] can support timestamps up to 31 July 31086,<ref name="Crazy time, Stanford, 1997">{{Cite web|date=1997-07-24|title=Why is Wednesday, November 17, 1858 the base time for OpenVMS (VAX VMS)?|url=https://www.slac.stanford.edu/~rkj/crazytime.txt|url-status=live|archive-url=https://web.archive.org/web/19970724202734/https://www.slac.stanford.edu/~rkj/crazytime.txt|archive-date=1997-07-24|access-date=2020-01-08|website=]|df=dmy-all}}</ref> the C runtime library (CRTL) uses 32-bit integers for <code>time_t</code>.<ref name="vsi-c-rtl">{{cite web|date=November 2020|title=VSI C Run-Time Library Reference Manual for OpenVMS Systems|url=https://vmssoftware.com/docs/VSI_CRTL_REF.pdf|access-date=2021-04-17|publisher=VSI|archive-date=17 April 2021|archive-url=https://web.archive.org/web/20210417113107/https://vmssoftware.com/docs/VSI_CRTL_REF.pdf|url-status=dead}}</ref> As part of Y2K compliance work that was carried out in 1998, the CRTL was modified to use unsigned 32-bit integers to represent time; extending the range of <code>time_t</code> up to 7 February 2106.<ref>{{cite web|title=OpenVMS and the year 2038|url=https://www.zx.net.nz/mirror/h71000.www7.hp.com/2038.html|access-date=2021-04-17|publisher=HP|archive-date=17 April 2021|archive-url=https://web.archive.org/web/20210417113108/https://www.zx.net.nz/mirror/h71000.www7.hp.com/2038.html|url-status=live}}</ref> | |||
* ] since version 7.2, released 2002-02-04, stores timestamp WITHOUT TIMEZONE as 64-bit.<ref>{{cite web|title=PostgreSQL Release 7.2|date=January 2012|url=https://www.postgresql.org/docs/7.2/release-7-2.html|access-date=25 April 2024|archive-date=26 April 2024|archive-url=https://web.archive.org/web/20240426022618/https://www.postgresql.org/docs/7.2/release-7-2.html|url-status=live}}</ref>{{failed verification|date=May 2024}} Prior versions already stored timestamp as 64-bit.{{citation needed|date=May 2024}} | |||
* As of ] 8.0.28, released in January 2022, the functions <code>FROM_UNIXTIME()</code>, <code>UNIX_TIMESTAMP()</code>, and <code>CONVERT_TZ()</code> handle 64-bit values on platforms that support them. This includes 64-bit versions of Linux, macOS, and Windows.<ref>{{cite web|title=What Is New in MySQL 8.0|url=https://dev.mysql.com/doc/refman/8.0/en/mysql-nutshell.html#mysql-nutshell-additions|website=dev.mysql.com}}</ref><ref>{{cite web|title=Changes in MySQL 8.0.28 (2022-01-18, General Availability)|url=https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-28.html|website=dev.mysql.com|access-date=14 May 2024|archive-date=8 December 2023|archive-url=https://web.archive.org/web/20231208180456/https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-28.html|url-status=live}}</ref> In older versions, built-in functions like <code>UNIX_TIMESTAMP()</code> will return 0 after 03:14:07 ] on 19 January 2038.<ref>{{cite web|title=MySQL Bugs: #12654: 64-bit unix timestamp is not supported in MySQL functions|url=https://bugs.mysql.com/bug.php?id=12654|website=bugs.mysql.com|access-date=28 March 2017|archive-date=29 March 2017|archive-url=https://web.archive.org/web/20170329045924/https://bugs.mysql.com/bug.php?id=12654|url-status=live}}</ref> | |||
* As of ] 11.5.1, released in May 2024, the data type <code>TIMESTAMP</code> and functions <code>FROM_UNIXTIME()</code>, <code>UNIX_TIMESTAMP()</code>, and <code>CONVERT_TZ()</code> handle unsigned 32-bit values on 64-bit versions of Linux, macOS, and Windows.<ref>{{cite web|title=MariaDB 11.5.1 Release Notes|url=https://mariadb.com/kb/en/mariadb-11-5-1-release-notes/}}</ref> This extended the range to 2106-02-07 06:28:15 and allowed users to store such timestamp values in tables without changing the storage layout and thus staying fully compatible with existing user data. | |||
* Starting with ] 2005, the CRT uses a 64-bit <code>time_t</code> unless the <code>_USE_32BIT_TIME_T</code> preprocessor macro is defined.<ref>{{Cite web |last= |date=2023-05-25 |title=Microsoft C/C++ change history 2003 - 2015 |url=https://learn.microsoft.com/en-us/cpp/porting/visual-cpp-change-history-2003-2015 |access-date=2024-08-13 |website=learn.microsoft.com |language=en-us}}</ref> However, the ] itself is unaffected by the year 2038 bug, as ] internally tracks time as the number of 100-nanosecond intervals since 1 January 1601 in a 64-bit signed integer, which will not overflow until year ].<ref>{{Cite web |last= |date=2021-01-07 |title=About Time - Win32 apps |url=https://learn.microsoft.com/en-us/windows/win32/sysinfo/about-time |access-date=2024-08-13 |website=learn.microsoft.com |language=en-us}}</ref> | |||
== See also == | == See also == | ||
* ] lists other similar problems, often caused by rollover similar to the cause of this year 2038 problem. | |||
* ] | |||
* A ] will coincidentally happen later in 2038, for a different reason than this year 2038 problem. | |||
* ] | |||
* ] | |||
== Notes == | |||
* ] | |||
{{notelist}} | |||
* ] | |||
* ] | |||
== References == | |||
* ] | |||
{{reflist}} | |||
== External links == | == External links == | ||
* ] Wiki | |||
* | |||
* |
* | ||
* |
* | ||
* |
* | ||
* | |||
*{{Cite web |title=Solving the Year 2038 problem in the Linux kernel |url=https://opensource.com/article/19/1/year2038-problem-linux-kernel }} | |||
* | |||
*{{cite news |url=https://www.bbc.com/future/article/20150505-the-numbers-that-lead-to-disaster |title=The number glitch that can lead to catastrophe |work=BBC Future |first=Chris |last=Baraniuk |date=5 May 2015}} | |||
* {{cite web|last=Clewett|first=James|title=2,147,483,647 – The End of Time |url=http://www.numberphile.com/videos/unix_time.html|website=Numberphile|publisher=]|access-date=7 April 2013|archive-url=https://web.archive.org/web/20170522031114/http://www.numberphile.com/videos/unix_time.html|archive-date=22 May 2017|url-status=dead}} | |||
{{Year-related problems}} | |||
] | |||
{{Doomsday}} | |||
] | |||
] | |||
] | |||
] | |||
{{Use dmy dates|date=August 2019}} | |||
] | |||
] | |||
] | ] | ||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] |
Latest revision as of 19:17, 25 December 2024
Computer software bug occurring in 2038The year 2038 problem (also known as Y2038, Y2K38, Y2K38 superbug or the Epochalypse) 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 2 − 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.
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 2 − 1 inclusive. Consequently, if a signed 32-bit integer is used to store Unix time, the latest time that can be stored is 2 − 1 (2,147,483,647) seconds after epoch, which is 03:14:07 on Tuesday, 19 January 2038. 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:
- File systems that use 32 bits to represent times in inodes
- Databases with 32-bit time fields
- Database query languages (such as SQL) that have
UNIX_TIMESTAMP()
-like commands
Embedded systems
Embedded systems that use dates for either computation or diagnostic logging are most likely to be affected by the Y2038 problem. 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.
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).
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.
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. Changing time_t
to an unsigned 32-bit integer, which would extend the range to 2106 (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. 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).
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 292,000 years at microsecond resolution. In particular, Java's and JavaScript's use of 64-bit signed integers to represent absolute timestamps 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 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
- Starting with Ruby version 1.9.2 (released on 18 August 2010), the bug with year 2038 is fixed, by storing time in a signed 64-bit integer on systems with 32-bit
time_t
. - 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-bittime_t
are supported via a binary compatibility layer, but such older applications will still suffer from the Y2038 problem. - OpenBSD since version 5.5, released in May 2014, also uses a 64-bit
time_t
for both 32-bit and 64-bit architectures. In contrast to NetBSD, there is no binary compatibility layer. Therefore, applications expecting a 32-bittime_t
and applications using anything different fromtime_t
to store time values may break. - Linux originally used a 64-bit
time_t
for 64-bit architectures only; the pure 32-bit ABI was not changed due to backward compatibility. Starting with version 5.6 of 2020, 64-bittime_t
is supported on 32-bit architectures, too. This was done primarily for the sake of embedded Linux systems. - GNU C Library since version 2.34 (released August 2021), added support for using 64-bit
time_t
on 32-bit platforms with appropriate Linux versions. This support can be activated by defining preprocessor macro_TIME_BITS
to64
when compiling source code. - FreeBSD uses 64-bit
time_t
for all 32-bit and 64-bit architectures except 32-bit i386, which uses signed 32-bittime_t
instead. - The x32 ABI for Linux (which defines an environment for programs with 32-bit addresses but running the processor in 64-bit mode) uses a 64-bit
time_t
. Since it was a new environment, there was no need for special compatibility precautions. - Network File System version 4 has defined its time fields as
struct nfstime4 {int64_t seconds; uint32_t nseconds;}
since December 2000. Version 3 supports unsigned 32-bit values asstruct nfstime3 {uint32 seconds; uint32 nseconds;};
. Values greater than zero for the seconds field denote dates after the 0-hour, January 1, 1970. Values less than zero for the seconds field denote dates before the 0-hour, January 1, 1970. In both cases, the nseconds (nanoseconds) field is to be added to the seconds field for the final time representation. - The ext4 filesystem, when used with inode sizes larger than 128 bytes, has an extra 32-bit field per timestamp, of which 30 bits are used for the nanoseconds part of the timestamp, and the other 2 bits are used to extend the timestamp range to the year 2446.
- The XFS filesystem, starting with Linux 5.10, has an optional "big timestamps" feature which extends the timestamp range to the year 2486.
- While the native APIs of OpenVMS can support timestamps up to 31 July 31086, the C runtime library (CRTL) uses 32-bit integers for
time_t
. As part of Y2K compliance work that was carried out in 1998, the CRTL was modified to use unsigned 32-bit integers to represent time; extending the range oftime_t
up to 7 February 2106. - PostgreSQL since version 7.2, released 2002-02-04, stores timestamp WITHOUT TIMEZONE as 64-bit. Prior versions already stored timestamp as 64-bit.
- As of MySQL 8.0.28, released in January 2022, the functions
FROM_UNIXTIME()
,UNIX_TIMESTAMP()
, andCONVERT_TZ()
handle 64-bit values on platforms that support them. This includes 64-bit versions of Linux, macOS, and Windows. In older versions, built-in functions likeUNIX_TIMESTAMP()
will return 0 after 03:14:07 UTC on 19 January 2038. - As of MariaDB 11.5.1, released in May 2024, the data type
TIMESTAMP
and functionsFROM_UNIXTIME()
,UNIX_TIMESTAMP()
, andCONVERT_TZ()
handle unsigned 32-bit values on 64-bit versions of Linux, macOS, and Windows. This extended the range to 2106-02-07 06:28:15 and allowed users to store such timestamp values in tables without changing the storage layout and thus staying fully compatible with existing user data. - Starting with Visual C++ 2005, the CRT uses a 64-bit
time_t
unless the_USE_32BIT_TIME_T
preprocessor macro is defined. However, the Windows API itself is unaffected by the year 2038 bug, as Windows internally tracks time as the number of 100-nanosecond intervals since 1 January 1601 in a 64-bit signed integer, which will not overflow until year 30,828.
See also
- Time formatting and storage bugs lists other similar problems, often caused by rollover similar to the cause of this year 2038 problem.
- A GPS week number rollover will coincidentally happen later in 2038, for a different reason than this year 2038 problem.
Notes
- Unless otherwise specified, all the numbers provided in this article have been derived using two's complement for signed integer arithmetic.
- GPS suffers its own time counter overflow problem known as GPS Week Number Rollover.
References
- ^ "Is the Year 2038 problem the new Y2K bug?". The Guardian. 17 December 2014. Archived from the original on 25 January 2022. Retrieved 11 October 2018.
- Bergmann, Arnd (6 February 2020). "The end of an Era". Linaro. Archived from the original on 7 February 2020. Retrieved 13 September 2020.
- Wagenseil, Paul (28 July 2017). "Digital 'Epochalypse' Could Bring World to Grinding Halt". Tom's Guide. Archived from the original on 29 November 2021. Retrieved 13 September 2020.
- ^ "The Future Lies Ahead". 28 June 2006. Archived from the original on 28 November 2006. Retrieved 19 November 2006.
- ^ Weird "memory leak" problem in AOLserver 3.4.2/3.x Archived 4 January 2010 at the Wayback Machine 12 May 2006
- "Epoch Time". unixtutoria. 15 March 2019. Archived from the original on 13 April 2023. Retrieved 13 April 2023.
- Diomidis Spinellis (2006). Code quality: the open source perspective. Effective software development series in Safari Books Online (illustrated ed.). Adobe Press. p. 49. ISBN 978-0-321-16607-4.
- "ZTE Blade running Android 2.2 has 2038 problems". Archived from the original on 19 May 2022. Retrieved 20 November 2018.
- "ARB Test Methods / Procedures". ARB.ca.gov. California Air Resources Board. Archived from the original on 18 November 2016. Retrieved 12 September 2013.
- "DRAFT: Y2038 Proofness Design". Archived from the original on 21 September 2019. Retrieved 25 May 2024.
- "When does the 64-bit Unix time_t really end?". Archived from the original on 23 September 2022. Retrieved 24 September 2022.
- Felts, Bob (17 April 2010). "The End of Time". Stablecross.com. Archived from the original on 11 October 2012. Retrieved 19 March 2012.
- "Unununium Time". Archived from the original on 8 April 2006. Retrieved 19 November 2006.
- Sun Microsystems. "Java API documentation for System.currentTimeMillis()". Archived from the original on 30 September 2017. Retrieved 29 September 2017.
- "TAI64". Archived from the original on 26 September 2012. Retrieved 4 September 2012.
- "Ruby 1.9.2 is released". 18 August 2010. Archived from the original on 8 April 2022. Retrieved 1 April 2022.
- "time.c: use 64bit arithmetic even on platforms with 32bit VALUE". GitHub. Archived from the original on 3 November 2023. Retrieved 3 November 2023.
- "Announcing NetBSD 6.0". 17 October 2012. Archived from the original on 15 January 2016. Retrieved 18 January 2016.
- "OpenBSD 5.5 released (May 1, 2014)". 1 May 2014. Archived from the original on 22 December 2015. Retrieved 18 January 2016.
- ^ Jonathan Corbet (14 August 2013). "Pondering 2038". LWN.net. Archived from the original on 4 March 2016. Retrieved 9 March 2016.
- "LKML: Arnd Bergmann: [GIT PULL] y2038: core, driver and file system changes". lkml.org. Archived from the original on 14 February 2020. Retrieved 30 January 2020.
- O'Donell, Carlos (2 August 2021). "The GNU C Library version 2.34 is now available". Sourceware. Archived from the original on 30 April 2024. Retrieved 30 April 2024.
- "arch". www.freebsd.org. Archived from the original on 26 September 2018. Retrieved 26 September 2018.
- Haynes, Thomas; Noveck, David, eds. (March 2015). "Structured Data Types". Network File System (NFS) Version 4 Protocol. sec. 2.2. doi:10.17487/RFC7530. RFC 7530.
- Staubach, Peter; Pawlowski, Brian; Callaghan, Brent (June 1995). "NFS Version 3 Protocol Specification". Retrieved 25 May 2024.
- "ext4 Data Structures and Algorithms". Archived from the original on 13 September 2022. Retrieved 13 September 2022.
- Michael Larabel (15 October 2020). "XFS File-System With Linux 5.10 Punts Year 2038 Problem To The Year 2486". Phoronix. Archived from the original on 13 September 2022. Retrieved 13 September 2022.
- "Why is Wednesday, November 17, 1858 the base time for OpenVMS (VAX VMS)?". Stanford University. 24 July 1997. Archived from the original on 24 July 1997. Retrieved 8 January 2020.
- "VSI C Run-Time Library Reference Manual for OpenVMS Systems" (PDF). VSI. November 2020. Archived from the original (PDF) on 17 April 2021. Retrieved 17 April 2021.
- "OpenVMS and the year 2038". HP. Archived from the original on 17 April 2021. Retrieved 17 April 2021.
- "PostgreSQL Release 7.2". January 2012. Archived from the original on 26 April 2024. Retrieved 25 April 2024.
- "What Is New in MySQL 8.0". dev.mysql.com.
- "Changes in MySQL 8.0.28 (2022-01-18, General Availability)". dev.mysql.com. Archived from the original on 8 December 2023. Retrieved 14 May 2024.
- "MySQL Bugs: #12654: 64-bit unix timestamp is not supported in MySQL functions". bugs.mysql.com. Archived from the original on 29 March 2017. Retrieved 28 March 2017.
- "MariaDB 11.5.1 Release Notes".
- "Microsoft C/C++ change history 2003 - 2015". learn.microsoft.com. 25 May 2023. Retrieved 13 August 2024.
- "About Time - Win32 apps". learn.microsoft.com. 7 January 2021. Retrieved 13 August 2024.
External links
- Y2038 Proofness Design glibc Wiki
- Entry in How Stuff Works
- The Project 2038 Frequently Asked Questions
- Critical and Significant Dates 2038
- A 2038-safe replacement for time.h on 32 bit systems
- "Solving the Year 2038 problem in the Linux kernel".
- iPhone troubleshooting
- Baraniuk, Chris (5 May 2015). "The number glitch that can lead to catastrophe". BBC Future.
- Clewett, James. "2,147,483,647 – The End of Time [Unix]". Numberphile. Brady Haran. Archived from the original on 22 May 2017. Retrieved 7 April 2013.
Year-related problems | |
---|---|
Decimal or BCD storage related | |
Binary storage related | |
Hexadecimal storage related | |
Categories: