古惑狼游戏牵扯出的硬件 bug
It's kind of painful to re-live this one. As a programmer, you learn to blame your code first, second, and third... and somewhere around 10,000th you blame the compiler. Well down the list after that, you blame the hardware.
回想起这个 bug,仍然让我感觉有些痛苦。作为一个程序员,在发现 bug 时,你学会了首先在自己代码中找问题,一次、两次、三次…… 或许在测试一万次之后,你会把问题归咎于编译器。只有在这所有的都不起作用之后,你才会把问题归咎于硬件。
This is my hardware bug story.
这是我遭遇硬件 bug 的故事。
Among other things, I wrote the memory card (load/save) code for Crash Bandicoot. For a swaggering game coder, this is like a walk in the park; I expected it would take a few days. I ended up debugging that code for six weeks. I did other stuff during that time, but I kept coming back to this bug -- a few hours every few days. It was agonizing.
抛开别的不说,我曾为古惑狼(Crash Bandicoot,PS1 游戏)写存储卡(读写)代码。对于一个自大的游戏程序员,这就像是在公园里散步一样轻松愉快;我预计只要几天就可以写完。我最终用了六个礼拜把那些代码调试完毕。在此期间我也做过一些其他的事情,但却一直绕不开这个 bug—— 每几天内就要花上好几个小时来处理。这个 bug 实在烦人。
The symptom was that you'd go to save your progress and it would access the memory card, and almost all the time, it worked normally... But every once in a while the write or read would time out... for no obvious reason. A short write would often corrupt the memory card. The player would go to save, and not only would we not save, we'd wipe their memory card. D'Oh.
这个 bug 的症状是,当你需要保存你的进度时,代码会访问存储卡,而大部分情况下没有什么问题… 但是偶尔读写会超时… 没有任何明显的原因。一个简短的写入经常毁掉存储卡。玩家要保存进度,我们不仅不保存,还擦除他们存储卡上的全部东西。天哪。
After a while, our producer at Sony, Connie Booth, began to panic. We obviously couldn't ship the game with that bug, and after six weeks I still had no clue what the problem was. Via Connie we put the word out to other PlayStation 1 developers -- had anybody seen anything like this? Nope. Absolutely nobody had any problems with the memory card system.
过了一段时间,我们在 Sony 的制作人 Connie Booth 慌了。我们显然不能发布带有这个 bug 游戏,而六个星期之后我对于问题出在哪一点线索都没有。通过 Connie 我们向其他 PS1 开发者求助:有没有人出现过像我们这样的情况?没有。绝对没有任何人在存储卡系统上出现任何问题。
About the only thing you can do when you run out of ideas debugging is divide and conquer: keep removing more and more of the errant program's code until you're left with something relatively small that still exhibits the problem. You keep carving parts away until the only stuff left is where the bug is.
在你绞尽脑汁之后,你能做的唯一一个调试方法就是分而治之:一点点去除错误程序中的代码,直到留下的代码相对很少,但仍然表现出问题。像雕刻一样去除没有问题的代码,留下的就是你的 bug 所在。