Time formatting and storage bugs

From Wikipedia, the free encyclopedia
Jump to: navigation, search

In computer science, time formatting and storage bugs are a class of software bugs which may cause time and date calculation or display to be improperly handled. These are most commonly manifestations of arithmetic overflow, but can also be the result of other issues. The most well-known consequence of bugs of this type is the Y2K problem, but many other milestone dates or times exist that have caused or will cause problems depending on various programming deficiencies.

Contents

[edit] GPS date rollover

In the last few months before the year 2000, two other date-related milestones occurred that received less publicity than the then-impending Y2K problem.

The first problem was related to GPS devices: GPS dates are expressed as a week number and a day-of-week number, with the week number transmitted as a ten-bit value. This means that every 1,024 weeks (about 19.6 years) after 6 January 1980 (the GPS epoch), the date resets again to that date; this happened for the first time on 21 August 1999.[1] To address this concern, modernized GPS navigation messages use a 13-bit field, which only repeats every 8,192 weeks (157 years), and will not return to zero until near the year 2137.

[edit] 9/9/99

The second pre-Y2K milestone occurred in the following month. In many programs or data sets, "9/9/99" was used as a code value to indicate either an unresolved date or as a terminator to indicate no further data was in the set. This raised issues when the actual date this represents, 9 September 1999, actually arrived.[1]

[edit] Two-digit year representations

Follow-on problems caused by certain temporary fixes to the Y2K problem will crop up at various points in the 21st century. Some programs were made Y2K-compliant by continuing to use two digit years, but picking an arbitrary year prior to which those years are interpreted as 20xx, and after which are interpreted as 19xx.[2]

For example, a program may have been changed so that it treats two-digit year values 00-68 as referring to 2000 through 2068, and values 69-99 as referring to 1969 through 1999.[3] Such a program will not be able to correctly deal with years beyond 2068.

For applications wanting to calculate the birth year (or other passed year), such an algorithm has long been used to overcome the Year 1900 problem, but it has failed to recognise people over 100 years old.

[edit] Serial presence detect (SPD) EEPROMs

The SPD EEPROM on modern computer memory modules contains a single-byte binary-coded decimal (two digit) year-of-manufacture code at offset +93 (0x5D).[4] Due to the 18-24 month generational cycle in computer technology this should not be a problem.

[edit] Year 2011 in Taiwan

Taiwan (known formally as the Republic of China) officially uses the Minguo calendar, which considers the Gregorian year 1912 to be its year 1. Thus, the Gregorian year 2011 is the ROC year 100, its first 3-digit year.[5]

[edit] Year 2038

The original implementation of the Unix operating system stored system time as a 32-bit signed integer representing the number of seconds past the Unix epoch: midnight UTC, 1 January 1970. This value will roll over on 19 January 2038. This problem has been addressed in most modern Unix and Unix-like operating systems by storing system time as a 64-bit signed integer, although individual applications, protocols, and file formats will still need to be changed as well.

[edit] Year 2042

On 17 September 2042 at 23:53:47.370496 TAI, the Time of Day Clock on S/370 IBM mainframe and its successors, including the current zSeries, will roll over.[6] The UTC time will be a few seconds earlier, due to leap seconds.

The TOD Clock is implemented as a 64-bit count of 2−12 microsecond (0.244 ns) units, and the standard base is 1 January 1900. The actual resolution depends on the model, but the format is consistent, and will therefore roll over after 252 microseconds.

The TOD Clock value is accessible to user mode programs, and is often used for timing and for generating unique IDs for events.

While IBM has defined and implemented a longer (128-bit) hardware format on recent machines, which extends the timer on both ends, many programs continue to rely on the 64-bit format which remains as an accessible subset of the longer timer.

[edit] Days 32,768 and 65,536

Programs that store dates as the number of days since an arbitrary date (or epoch) are vulnerable to roll-over or wrap-around effects if the values are not wide enough to allow the date values to span a large enough time range expected for the application. Signed 16-bit binary values roll over after 32,768 (215) days from the epoch date, producing negative values. Some mainframe systems experienced software failures because they had encoded dates as the number of days since 1 January 1900, which produced unexpected negative day numbers on the roll-over date of 18 September 1989. Similarly, unsigned 16-bit binary days counts overflow after 65,536 (216) days, which are truncated to zero values. For software using an epoch of 1 January 1900, this will occur on 6 June 2079.[7]

[edit] Year 2107

The timestamp stored in FAT filesystems, introduced with MS-DOS, and applications that convert other formats to the FAT/MS-DOS format, will overflow at the end of 2107. The FAT/MS-DOS timestamp is stored in the directory entry with the year represented as an unsigned seven bit number (0-127), relative to 1980.

[edit] Year 10,000

The year 10,000 will be the first Gregorian year with five digits. Although many people at first consider this year to be so far distant that a problem of this type will never actually occur, certain classes of calculations in disciplines such as astronomy and physics already need to work with years of this magnitude and greater. These applications also have to deal with the Year zero problem.

[edit] Years 32,768 and 65,536

Programs that process years as 16-bit values may encounter problems dealing with either the year 32,768 or 65,536, depending on whether the value is treated as a signed or unsigned integer.

In the case of the year 32,768 problem, years after 32,767 may be interpreted as negative numbers, beginning with -32,768.[8] The year 65,536 problem is more likely to manifest itself by representing the year 65,536 as the year 0.[9]

[edit] "Problems" that aren't problems

Certain problematic years occur so far in the future—well beyond the likely lifespan of Earth or the Sun, and even past some predictions of the lifetime of the universe—that they are mainly referenced as matters of theoretical interest, jokes, or indications that a related problem truly is solved for any reasonable definition of "solved".

  • The year 292,277,026,296 (2.9*1011) and 584,554,051,223 (5.8*1011) problems: the years that 64-bit Unix time becomes negative (assuming a signed number) or reset to zero (for an unsigned representation).[10]
  • The year 5,391,559,471,918,239,497,011,222,876,596 (5.4*1030) and 10,783,118,943,836,478,994,022,445,751,223 (1.1*1031) problems: the years that 128-bit Unix time becomes negative (assuming a signed number) or reset to zero (for an unsigned representation).

Note: these year values are based on an average year being 365.2425 days, which matches the 4/100/400 leap year rules of the common Gregorian calendar. Additional adjustments to the calendar over intervals this long are unavoidable (ignoring that all of these times far exceed the likely existence of the Earth), so the year numbers should be considered approximate.

[edit] See also

[edit] References

  1. ^ a b Janis L. Gogan (1999-08-09). "Applications To The Nines". InformationWeek. http://www.informationweek.com/747/47uwjg.htm. Retrieved 2008-01-21. 
  2. ^ "Identifying and Correcting Dates with Two-Digit Years". University of Illinois at Chicago. 2001-12-21. http://www.uic.edu/depts/accc/software/isodates/fixing.html. Retrieved 2010-01-19.  See "Example 1: 100 Year Fixed Window, 1973 to 2072"
  3. ^ date - write the date and time, The Open Group Base Specifications Issue 6. IEEE Std 1003.1, 2004 Edition
  4. ^ "JEDEC Standard No. 21-C - 4.1.2.4 – Appendix D, Rev. 1.0 : SPD’s for DDR SDRAM". http://www.jedec.org/sites/default/files/docs/4_01_02_04R13.pdf. Retrieved 12 May 2011. 
  5. ^ Pinyin news » Taiwan’s Y1C problem
  6. ^ Dhondy, Noshir; Eckam, Hans-Peter; Jaeckel, Marcel; McDonough, Jeff; Ng, George; Packheiser, Frank; Tanguy, Bernard (2009-07-01), Server Time Protocol Planning Guide, IBM Redbooks (second ed.), IBM, ISBN 0-7384-3276-8, http://www.redbooks.ibm.com/abstracts/sg247280.html, retrieved 2010-04-08 
  7. ^ J. R. Stockton (2009-04-12). "Critical and Significant Dates". http://www.merlyn.demon.co.uk/critdate.htm. Retrieved 2009-08-20. 
  8. ^ Top 10 Fun Reasons why you Should Stop Using Delphi, now!
  9. ^ http://libsnap.dom.edu/ClasPlus/ADDONS/Y2K.TXT
  10. ^ "Project 2038 FAQ". 2007-08-15. http://www.deepsky.com/~merovech/2038.html. Retrieved 2010-03-05. 
Personal tools
Namespaces
Variants
Actions
Navigation
Interaction
Toolbox
Print/export