Home > Geek > 微软 Zune 30 又现千年虫Bug

微软 Zune 30 又现千年虫Bug

在2008年的最后一天,无数的Zune 30 用户忽然发现自己的MP3无法正常播放,而专家给出的解决方法是:

“let the Zune run out of battery and the clock bug will essentially fix itself”

(让电池耗尽或这一天不要用Zune,到第二天就会自己好起来),但是这个Bug会四年后的今天再现。

在国外的一个论坛上看到一个帖子说Bug产生的原因, 当时闰年的时候天数是366天,下面的是Zune的 时钟驱动:

year = ORIGINYEAR; /* = 1980 */

while (days > 365)
{
    if (IsLeapYear(year))
    {
        if (days > 366)  // 当在闰年的时候,days = 366 是出现死循环
        {
            days -= 366;
            year += 1;
        }
    }
    else
    {
        days -= 365;
        year += 1;
    }
}

我们会发现当 days = 366 天的时候,while 就会进入死循环,直到24小时过后,才能正常工作。

当然还有一种修改驱动的方法:

year = ORIGINYEAR; /* = 1980 */

while (days > 365)
{
    if (IsLeapYear(year))
    {
        if (days > 366)
        {
            days -= 366;
            year += 1;
        }
        else  // 可以修复Bug
        {
            break;
        }
    }
    else
    {
        days -= 365;
        year += 1;
    }
}
参考:
1.Cause of Zune 30 leapyear problem ISOLATED!
http://www.zuneboards.com/forums/zune-news/38143-cause-zune-30-leapyear-problem-isolated.html
2.Zune 时钟驱动
http://pastie.org/349916
3.The Day the Zunes Stood Still: Update
http://www.crunchgear.com/2008/12/31/the-day-the-zunes-stood-still-update/

–EOF–

Categories: Geek Tags: ,
  1. No comments yet.
  1. No trackbacks yet.

Additional comments powered by BackType