My Vision,     
     My World

2008.11.17


2008.08.07


2008.06.21


2008.06.05


2008.05.07


2008.02.12


2007.12.18


2007.10.07


2007.06.16-03


2007.06.16-02


Archive

Archived Post

Zune Crisis Averted

Much to Microsoft’s relief, the bug that stopped all Zune 30 players yesterday indeed was tied to leap year, and went away today. Jim directed me to the fact that the bug was discovered to be part of the Zune’s clock driver. The Zune uses an ARM processor made by Freescale, and the offending code (which was written by Freescale, not Microsoft) is freely available on their website:

year = ORIGINYEAR; /* = 1980 */

while (days > 365)
{
    if (IsLeapYear(year))
    {
        if (days > 366)
        {
            days -= 366;
            year += 1;
        }
    }
    else
    {
        days -= 365;
        year += 1;
    }
}

If you inspect this code fragment, you’ll see that if ‘days’ = 366, it enters into an infinite loop. It’s a simple bug that could be fixed by replacing ‘>’ with ‘>=’.

What makes this interesting to me is the fact that it seems Freescale is responsible for the bug. The ARM family are among the most popular embedded processors. How popular? In 2006 alone, a staggering 2.5 billion (yes, billion with a B) ARM devices were put into products ranging from things like my Nintendo DS to my Wireless router. Fortunately this bug seems isolated to only the Zune 30’s ARM design, however if it had been present in all ARM processors the pandemonium which would have ensued during yesterday’s bug period would have been an amazing event to witness. Or maybe I wouldn’t have been able to witness it, since my router would have stopped working. Truly it would have been a ‘wrath of God’-type moment, with all the effects we thought would happen with Y2K, but actually happening, and happening without any advance warning.

Yet, that didn’t happen. Instead Microsoft is left to clean up its personal PR mess.

collapse Michael Says:

Also amazing - don’t they have a standard function for handling leap years? They re-write it for all devices?

 
collapse dyre Says:

I think changing the ‘>’ to a ‘>=’ would result in the Zune thinking that December 31st of a Leap year was January 0th of the next year.

I think this code would probably work:

while ((!isLeapYear(year) && days > 365)
|| (isLeapYear(year) && days > 366))
{
if (IsLeapYear(year))
{
days -= 366;
year += 1;
}
else
{
days -= 365;
year += 1;
}
}

 
collapse Colecago Says:

while (!ipod)
{
work = no;
}

heh, just kidding. The only reason I got my ipod was because it was a decent deal used, and honestly, I use it mostly for web surfing and getting my email. A smartphone could do that for me.