Zune bug explained in detail

Wednesday, December 31st, 2008

Devin Coldewey is a Seattle-based writer and photographer. He has written for the TechCrunch network since 2007. Some posts he’d like you to read: The Dangers of Externalizing Knowledge | Generation i | Surveillant Society | Choose Two | Frame Wars | The User’s Manifesto | Our Great Sin His personal website is coldewey.cc. → Learn More

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.

Tags: ,

Sponsored Ads

blog comments powered by Disqus

Sponsored Ads

Sponsored Ads

Events

Crunchies Awards
January 31, 2012
Davies Symphony Hall
San Francisco CA
Learn MoreBuy Tickets