Zune bug explained in detail

Next Story

Girly guitar controller for PS2

Earlier today, the sound of thousands of Zune owners crying out in terror made ripples across the blogosphere. The response from Microsoft is to wait until tomorrow and all will be well. You’re probably wondering, what kind of bug fixes itself?

Well, I’ve got the code here and it’s very simple, really; if you’ve taken an introductory programming class, you’ll see the error right away.

year = ORIGINYEAR; /* = 1980 */

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

You can see the details here, but the important bit is that today, the day count is 366. As you can see, the leap year is accounted for, but int “days” is too big for the main while loop to end the “if (days > 366)” has no else condition. So the thing just keeps running and running… until 24 hours have passed and int day receives a new value. At least, I think that’s what happens (it’s been a while since CS101).

Itsnotabigtruck, the poster who figured this out for everyone, notes that this will occur again in four years if they don’t do something. I’m guessing that they will.

blog comments powered by Disqus