DevDisasters
A Familiar Zune
The day(s) when leap years create havoc for programmers. A DevDisaster of many years.
On Wednesday, Dec. 31, 2008, Microsoft Zune owners across the world powered up their music players and watched their startup routines grind to a halt. Their Zunes were completely inoperable and would remain that way until New Year's Day.
It was all thanks to a simple bug in the Real Time Clock driver:
while (days > 365)
{
if (IsLeapYear(year))
{
if (days > 366)
{
days -= 366;
year += 1;
}
}
else
{
days -= 365;
year += 1;
}
}
Microsoft's "Z2K Bug" is hardly anything new. Leap year "bugs" have wreaked havoc for as long as computer programs have had to work with dates.
The Great Computer Shutdown
Wang Laboratories was an IT front-runner in 1984, employing nearly 30,000 people and bringing in $2 billion per year in revenue. One interesting security feature of Wang's minicomputer, the Wang VS, was File Expiration Dates. If someone, regardless of their security privileges, attempted to delete a file not past expiration, the OS would raise a flag, demanding the date be changed before deleting.
Like many OSes, the Wang VS and its apps used temporary files to do all sorts of things. Different modules of the OS and its apps relied on different functions for different date and time calculations.
Unfortunately, the temporary file creation module mistakenly incremented the zero-indexed day-of-year for all day-of-years that are equal to zero in a leap year. In other words, when Jan. 1, 1984 (day zero in a leap year), hit, the code set "Jan. 2, 1984" as a temporary file's expiration date.
Because temporary files are created and deleted in a matter of seconds, the OS was blocked from deleting its own files. One by one, processes in the Wang VS shut down and the computers ground to a halt. As boot-time activity included the creation and deletion of temporary files, the OS boot process couldn't complete. This effectively put every single Wang VS computer in an unbootable state.
Wang engineers and support techs worked around the clock to restore and fix all the broken computers. Thanks to a combination of the New Year's Day holiday and FedEx, most businesses only suffered a minor disruption of service.
Leaping Through the Years
A software vendor of mainframe security systems ran into similar trouble in 1988. Capers Jones, a software-engineering methodologies specialist, described what happened at the time: "Starting at midnight on Feb. 28, 1988, customers began to be locked out of their computers because Feb. 29 was not considered to be a valid date. By the time the company opened in the morning, hundreds of frantic telephone calls and faxes were arriving from clients all over the world."
On leap day 1992, there was a worldwide crash of e-mail servers running iMail. In addition, the state of Iowa's liquor licenses could not be renewed until March 1 because the state's computers couldn't handle a February with 29 days. Later that year, on Dec. 31, NCR's ATMs couldn't handle the 366th day of the year, causing thousands of customer transactions to be rejected.
Four years later, 60,000 people looking to purchase lottery tickets in Arizona were turned away on leap day in 1996 as a result of a vendor computer system failure. The 366th day of that year was eventful for a New Zealand-based aluminum smelter plant. Computers running the potlines ground to a halt, causing production to stop.
With all the hoopla over Y2K, many programmers seemed to forget that 2000 was, in fact, a leap year. Montreal was forced to shut down its taxation computer system after the program interpreted Feb. 29 as March 1, 1900. Several retail chains, including PetSmart, had serious leap day-related failures. And to wrap the year up, Norway's trains stopped working on Dec. 31 until one of the computer techs reset the system's date to Dec. 1.
Leap year 2004 certainly had its share of glitches, though some were more patchable than others. "The computer display in the 2004 model year Grand Prix shows the wrong day of the week," Pontiac spokesman Jim Hopson said about a bug in the company's cars. "Engineers overlooked the fact that 2004 is a leap year, with an extra day."
A 2008 Year in Review
Tell Us Your Tale
Each issue Alex Papadimoulis, publisher of the popular Web site The Daily WTF, recounts first-person tales of software development gone terribly wrong. Have you experienced the darker side of development? We want to publish your story. Send us your 300- to 600-word tale -- if we print it, you'll win $100 and an RDN T-shirt! E-mail your story to Senior Editor Kathleen Richards at krichards@1105media.com and use "DevDisasters" as the subject line. |
Despite decades of trouble, this past leap year reminded us that we still have a long way to go. On The Daily WTF, we received stories that ranged from custom-developed systems failing to a certain alcoholic beverage company telling all Web site visitors that they weren't old enough (the programmer tried to cast Feb. 29, 1987 as a date).
As for Microsoft, the Zune wasn't their only 2008 leap year gaffe:
- Exchange Server 2007 didn't believe that Feb. 29, 2008, was a real day.
- Older versions of Windows Mobile went from Feb. 29, 2008, to March 1, 2035.
- Small Business Server stamped leap day certificates with Feb. 29, 2013.
- SQL Server 2008 CTP wouldn't start on leap day 2008.
About the Author
Alex Papadimoulis is a managing partner at Inedo LLC and publisher of the Web site "Worse Than Failure" (WorseThanFailure.com). He writes the DevDisasters page in every issue of Redmond Developer News.