TONT 37903 有时候游戏的 bug 不玩到后期是体现不出来的


I didn’t debug it personally, but I know the people who did. During Windows XP development, a bug arrived on a computer game that crashed only after you got to one of the higher levels.

我并不亲自进行调试工作,不过我认识做这项工作的人。在 Windows XP 的开发过程中,曾经有款游戏的一个 bug,只有玩到进度比较深入的时候才会显现,并使游戏崩溃。

After many saved and restored games, the problem was finally identified.


The program does its video work in an offscreen buffer and transfers it to the screen when it’s done. When it draws text with a shadow, it first draws the text in black, offset down one and right one pixel, then draws it again in the foreground color.


So far so good.


Except that it didn’t check whether moving down and right one pixel was going to go beyond the end of the screen buffer.


That’s why it took until one of the higher levels before the bug manifested itself. Not until then did you accomplish a mission whose name contained a lowercase letter with a descender! Shifting the descender down one pixel caused the bottom row of pixels in the character to extend past the video buffer and start corrupting memory.

这就是为什么只有打到高等级的时候 bug 才会显现,因为直到那时才会完成一个任务,而这个任务的名字里有一个带下延部(注1)的小写字母!将这个字母的下延部下移1个像素,会导致底部一行的像素超出视频缓冲区,进而损毁了内存数据。

Once the problem was identified, fixing it was comparatively easy. The application compatibility team has a bag of tricks, and one of them is called “HeapPadAllocation”. This particular compatibility fix adds padding to every heap allocation so that when a program overruns a heap buffer, all that gets corrupted is the padding. Enable that fix for the bad program (specifying the amount of padding necessary, in this case, one row’s worth of pixels), and run through the game again. No crash this time.


What made this interesting to me was that you had to play the game for hours before the bug finally surfaced.




电子邮件地址不会被公开。 必填项已用*标注

 剩余字数 ( Characters available )

Your comment will be available after auditing.

Please DO NOT add any links in your comment, otherwise it would be identified as SPAM automatically and never be audited.