如何有效地報告 Bug

引言

爲公衆寫過軟件的人,大概都收到過很拙劣的bug(計算機程序代碼中的錯誤或程序運行時的瑕疵——譯者注)報告,例如:

在報告中說“不好用”;

所報告內容毫無意義;

在報告中用戶沒有提供足夠的信息;

在報告中提供了錯誤信息;

所報告的問題是由於用戶的過失而產生的;

所報告的問題是由於其他程序的錯誤而產生的;

所報告的問題是由於網絡錯誤而產生的;

這便是爲什麼“技術支持”被認爲是一件可怕的工作,因爲有拙劣的bug報告需要處理。然而並不是所有的bug報告都令人生厭:我在業餘時間維護自由軟件,有時我會收到非常清晰、有幫助並且“有內容”的bug報告。

在這裏我會盡力闡明如何寫一個好的bug報告。我非常希望每一個人在報告bug之前都讀一下這篇短文,當然我也希望用戶在給報告bug之前已經讀過這篇文章。

簡單地說,報告bug的目的是爲了讓程序員看到程序的錯誤。您可以親自示範,也可以給出能導致程序出錯的、詳盡的操作步驟。如果程序出錯了,程序員會收集額外的信息直到找到錯誤的原因;如果程序沒有出錯,那麼他們會請您繼續關注這個問題,收集相關的信息。

在bug報告裏,要設法搞清什麼是事實(例如:“我在電腦旁”和“XX出現了”)什麼是推測(例如:“我問題可能是出在……”)。如果願意的話,您可以省去推測,但是千萬別省略事實。

當您報告bug的時候(既然您已經這麼做了),一定是希望bug得到及時修正。所以此時針對程序員的任何過激或褻瀆的言語(甚至謾罵)都是與事無補 的——因爲這可能是程序員的錯誤,也有可能是您的錯誤,也許您有權對他們發火,但是如果您能多提供一些有用的信息(而不是激憤之詞)或許bug會被更快的 修正。除此以外,請記住:如果是免費軟件,作者提供給我們已經是出於好心,所以要是太多的人對他們無禮,他們可能就要“收起”這份好心了。

“程序不好用”

程序員不是弱智:如果程序一點都不好用,他們不可能不知道。他們不知道一定是因爲程序在他們看來工作得很正常。所以,或者是您作過一些與他們不同的操作,或者是您的環境與他們不同。他們需要信息,報告bug也是爲了提供信息。信息總是越多越好。

許多程序,特別是自由軟件,會公佈一個“已知bug列表”。如果您找到的bug在列表裏已經有了,那就不必再報告了,但是如果您認爲自己掌握的信息比列表中的豐富,那無論如何也要與程序員聯繫。您提供的信息可能會使他們更簡單地修復bug。

本文中提到的都是一些指導方針,沒有哪一條是必須恪守的準則。不同的程序員會喜歡不同形式的bug報告。如果程序附帶了一套報告bug的準則,一定要讀。如果它與本文中提到的規則相抵觸,那麼請以它爲準。

如果您不是報告bug,而是尋求幫助,您應該說明您曾經到哪裏找過答案,(例如:我看了第四章和第五章的第二節,但我找不到解決的辦法。)這會使程序員瞭解用戶喜歡到哪裏去找答案,從而使程序員把幫助文檔做得更容易使用。

“演示給我看”

報告bug的最好的方法之一是“演示”給程序員看。讓程序員站在電腦前,運行他們的程序,指出程序的錯誤。讓他們看着您啓動電腦、運行程序、如何進行操作以及程序對您的輸入有何反應。

他們對自己寫的軟件瞭如指掌,他們知道哪些地方不會出問題,而哪些地方最可能出問題。他們本能地知道應該注意什麼。在程序真的出錯之前,他們可能已經注意到某些地方不對勁,這些都會給他們一些線索。他們會觀察程序測試中的每一個細節,並且選出他們認爲有用的信息。

這些可能還不夠。也許他們覺得還需要更多的信息,會請您重複剛纔的操作。他們可能在這期間需要與您交流一下,以便在他們需要的時候讓bug重新出 現。他們可能會改變一些操作,看看這個錯誤的產生是個別問題還是相關的一類問題。如果您不走運,他們可能需要坐下來,拿出一堆開發工具,花上幾個小時來好好地研究一下。但是最重要的是在程序出錯的時候讓程序員在電腦旁。一旦他們看到了問題,他們通常會找到原因並開始試着修改。

“告訴我該怎麼做”

如今是網絡時代,是信息交流的時代。我可以點一下鼠標把自己的程序送到俄羅斯的某個朋友那裏,當然他也可以用同樣簡單的方法給我一些建議。但是如果我的程序出了什麼問題,我不可能在他旁邊。“演示”是很好的辦法,但是常常做不到。

如果您必須報告bug,而此時程序員又不在您身邊,那麼您就要想辦法讓bug重現在他們面前。當他們親眼看到錯誤時,就能夠進行處理了。

確切地告訴程序員您做了些什麼。如果是一個圖形界面程序,告訴他們您按了哪個按鈕,依照什麼順序按的。如果是一個命令行程序,精確的告訴他們您鍵入了什麼命令。您應該儘可能詳細地提供您所鍵入的命令和程序的反應。

把您能想到的所有的輸入方式都告訴程序員,如果程序要讀取一個文件,您可能需要發一個文件的拷貝給他們。如果程序需要通過網絡與另一臺電腦通訊,您或許不能把那臺電腦複製過去,但至少可以說一下電腦的類型和安裝了哪些軟件(如果可以的話)。

“哪兒出錯了?在我看來一切正常哦!”

如果您給了程序員一長串輸入和指令,他們執行以後沒有出現錯誤,那是因爲您沒有給他們足夠的信息,可能錯誤不是在每臺計算機上都出現,您的系統可能 和他們的在某些地方不一樣。有時候程序的行爲可能和您預想的不一樣,這也許是誤會,但是您會認爲程序出錯了,程序員卻認爲這是對的。

同樣也要描述發生了什麼。精確的描述您看到了什麼。告訴他們爲什麼您覺得自己所看到的是錯誤的,最好再告訴他們,您認爲自己應該看到什麼。如果您只是說:“程序出錯了”,那您很可能漏掉了非常重要的信息。

如果您看到了錯誤消息,一定要仔細、準確的告訴程序員,這確實很重要。在這種情況下,程序員只要修正錯誤,而不用去找錯誤。他們需要知道是什麼出問題了,系統所報的錯誤消息正好幫助了他們。如果您沒有更好的方法記住這些消息,就把它們寫下來。只報告“程序出了一個錯”是毫無意義的,除非您把錯誤消息一塊報上來。

特殊情況下,如果有錯誤消息號,一定要把這些號碼告訴程序員。不要以爲您看不出任何意義,它就沒有意義。錯誤消息號包含了能被程序員讀懂的各種信息,並且很有可能包含重要的線索。給錯誤消息編號是因爲用語言描述計算機錯誤常常令人費解。用這種方式告訴您錯誤的所在是一個最好的辦法。

在這種情形下,程序員的排錯工作會十分高效。他們不知道發生了什麼,也不可能到現場去觀察,所以他們一直在搜尋有價值的線索。錯誤消息、錯誤消息號以及一些莫名其妙的延遲,都是很重要的線索,就像辦案時的指紋一樣重要,保存好。

如果您使用UNIX系統,程序可能會產生一個內核輸出(coredump)。內核輸出是特別有用的線索來源,別扔了它們。另一方面,大多數程序員不 喜歡收到含有大量內核輸出文件的EMAIL,所以在發郵件之前最好先問一下。還有一點要注意:內核輸出文件記錄了完整的程序狀態,也就是說任何祕密(可能 當時程序正在處理一些私人信息或祕密數據)都可能包含在內核輸出文件裏。

“出了問題之後,我做了……”

當一個錯誤或bug發生的時候,您可能會做許多事情。但是大多數人會使事情變的更糟。我的一個朋友在學校裏誤刪了她所有的Word文件,在找人幫忙 之前她重裝了Word,又運行了一遍碎片整理程序,這些操作對於恢復文件是毫無益處的,因爲這些操作搞亂了磁盤的文件區塊。恐怕在這個世界上沒有一種反刪 除軟件能恢復她的文件了。如果她不做任何操作,或許還有一線希望。

這種用戶彷彿一隻被逼到牆角的鼬(黃鼠狼、紫貂一類的動物——譯者注):背靠牆壁,面對死亡的降臨奮起反撲,瘋狂攻擊。他們認爲做點什麼總比什麼都不做強。然而這些在處理計算機軟件問題時並不適用。

不要做鼬,做一隻羚羊。當一隻羚羊面對料想不到的情況或受到驚嚇時,它會一動不動,是爲了不吸引任何注意,與此同時也在思考解決問題的最好辦法(如果羚羊有一條技術支持熱線,此時佔線。)。然後,一旦它找到了最安全的行動方案,它便去做。

當程序出毛病的時候,立刻停止正在做的任何操作。不要按任何健。仔細地看一下屏幕,注意那些不正常的地方,記住它或者寫下來。然 後慎重地點擊“確定” 或“取消”,選擇一個最安全的。學着養成一種條件反射——一旦電腦出了問題,先不要動。要想擺脫這個問題,關掉受影響的程序或者重新啓動計算機都不好,一 個解決問題的好辦法是讓問題再次產生。程序員們喜歡可以被重現的問題,快樂的程序員可以更快而且更有效率的修復bug。

“我想粒子的躍遷與錯誤的極化有關”

並不只是非專業的用戶纔會寫出拙劣的bug報告,我見過一些非常差的bug報告出自程序員之手,有些還是非常優秀的程序員。

有一次我與另一個程序員一起工作,他一直在找代碼中的bug,他常常遇到一個bug,但是不會解決,於是就叫我幫忙。“出什麼毛病了?”我問。而他 的回答卻總是一些關於bug的意見。如果他的觀點正確,那的確是一件好事。這意味着他已經完成了工作的一半,並且我們可以一起完成另一半工作。這是有效率 並有用的。

但事實上他常常是錯的。這就會使我們花上半個小時在原本正確的代碼裏來回尋找錯誤,而實際上問題出在別的地方。我敢肯定他不會對醫生這麼做。“大 夫,我得了Hydroyoyodyne(真是怪病——譯者),給我開個方子”,人們知道不該對一位醫生說這些。您描述一下症狀,哪個地方不舒服,哪裏疼、 起皮疹、發燒……讓醫生診斷您得了什麼病,應該怎樣治療。否則醫生會把您當做疑心病或精神病患者打發了,這似乎沒什麼不對。

做程序員也是一樣。即便您自己的“診斷”有時真的有幫助,也要只說“症狀”。“診斷”是可說可不說的,但是“症狀”一定要說。同樣,在bug報告裏面附上一份針對bug而做出修改的源代碼是有用處的,但它並不能替代bug報告本身。

如果程序員向您詢問額外的信息,千萬別應付。曾經有一個人向我報告bug,我讓他試一個命令,我知道這個命令不好用,但我是要看看程序會返回一個什 麼錯誤(這是很重要的線索)。但是這位老兄根本就沒試,他在回覆中說“那肯定不好用”,於是我又花了好些時間才說服他試了一下那個命令。

用戶多動動腦筋對程序員的工作是有幫助的。即使您的推斷是錯誤的,程序員也應該感謝您,至少您去幫助他們,使他們的工作變的更簡單。不過千萬別忘了報告“症狀”,否則只會使事情變得更糟。

“真是奇怪,剛纔還不好用,怎麼現在又好了?”

“間歇性錯誤”着實讓程序員發愁。相比之下,進行一系列簡單的操作便能導致錯誤發生的問題是簡單的。程序員可以在一個便於觀察的條件下重複那些操 作,觀察每一個細節。太多的問題在這種情況下不能解決,例如:程序每星期出一次錯,或者偶然出一次錯,或者在程序員面前從不出錯(程序員一離開就出錯。 ——譯者)。當然還有就是程序的截止日期到了,那肯定要出錯。

大多數“間歇性錯誤”並不是真正的“間歇”。其中的大多數錯誤與某些地方是有聯繫的。有一些錯誤可能是內存泄漏產生的,有一些可能是別的程序在不恰當的時候修改某個重要文件造成的,還有一些可能發生在每一個小時的前半個小時中(我確實遇到過這種事情)。

同樣,如果您能使bug重現,而程序員不能,那很有可能是他們的計算機和您的計算機在某些地方是不同的,這種不同引起了問題。我曾寫過一個程序,它的窗口可以蜷縮成一個小球呆在屏幕的左上角,它在別的計算機上只能在 800x600 的解析度工作,但是在我的機器上卻可以在 1024x768 下工作。

程序員想要了解任何與您發現的問題相關的事情。有可能的話您到另一臺機器上試試,多試幾次,兩次,三次,看看問題是不是經常發生。如果問題出現在您 進行了一系列操作之後,不是您想讓它出現它就會出現,這就有可能是長時間的運行或處理大文件所導致的錯誤。程序崩潰的時候,您要儘可能的記住您都做了些什 麼,並且如果您看到任何圖形,也別忘了提一下。您提供的任何事情都是有幫助的。即使只是概括性的描述(例如:當後臺有EMACS運行時,程序常常出錯), 這雖然不能提供導致問題的直接線索,但是可能幫助程序員重現問題。

最重要的是:程序員想要確定他們正在處理的是一個真正的“間歇性錯誤”呢,還是一個在另一類特定的計算機上纔出現的錯誤。他們想知道有關您計算機的 許多細節,以便了解您的機器與他們的有什麼不同。有許多細節都依仗特定的程序,但是有一件東西您一定要提供——版本號。程序的版本、操作系統的版本以及與 問題有關的程序的版本。

“我把磁盤裝進了 Windows……”

表意清楚在一份bug報告裏是最基本的要求。如果程序員不知道您說的是什麼意思,那您就跟沒說一樣。我收到的bug報告來自世界各地,有許多是來自 非英語國家,他們通常爲自己的英文不好而表示歉意。總的來說,這些用戶發來的bug報告通常是清晰而且有用的。幾乎所有不清晰的bug報告都是來自母語是 英語的人,他們總是以爲只要自己隨便說說,程序員就能明白。

  • 精確。如果做相同的事情有兩種方法,請說明您用的是哪一種。例如:“我選擇了‘載入’”,可能意味着“我用鼠標點擊‘載入’”或“我按下了‘ALT+L’”,說清楚您用了哪種方法,有時候這也有關係。
  • 詳細。信息寧多毋少!如果您說了很多,程序員可以略去一部分,可是如果您說的太少,他們就不得不回過頭再去問您一些問題。有一次我收到了一份bug報告只有一句話,每一次我問他更多事情時,他每次的回覆都是一句話,於是我花了幾個星期的時間纔得到了有用的信息。
  • 慎用代詞。諸如“它”,“窗體”這些詞,當它們指代不清晰的時候不要用。來看看這句話:“我運行了FooApp,它彈出一個警 告窗口,我試着關掉它,它就崩潰了。”這種表述並不清晰,用戶究竟關掉了哪個窗口?是警告窗口還是整個FooApp程序?您可以這樣說,“我運行 FooApp程序時彈出一個警告窗口,我試着關閉警告窗口,FooApp崩潰了。”這樣雖然羅嗦點,但是很清晰不容易產生誤解。
  • 檢查。重新讀一遍您寫的bug報告,覺得它是否清晰?如果您列出了一系列能導致程序出錯的操作,那麼照着做一遍,看看您是不是漏寫了一步。

小結:

  • bug報告的首要目的是讓程序員親眼看到錯誤。如果您不能親自做給他們看,給他們能使程序出錯的詳細的操作步驟。
  • 如果首要目的不能達成,程序員不能看到程序出錯。這就需要bug報告的第二個目的來描述程序的什麼地方出毛病了。詳細的描述每一件事情:您看到了什麼,您想看到什麼,把錯誤消息記下來,尤其是“錯誤消息號”。
  • 當您的計算機做了什麼您料想不到的事,不要動!在您平靜下來之前什麼都別做。不要做您認爲不安全的事。
  • 儘量試着自己“診斷”程序出錯的原因(如果您認爲自己可以的話)。即使做出了“診斷”,您仍然應該報告“症狀”。
  • 如果程序員需要,請準備好額外的信息。如果他們不需要,就不會問您要。他們不會故意爲難自己。您手頭上一定要有程序的版本號,它很可能是必需品。
  • 表述清楚,確保您的意思不能被曲解。
  • 總的來說,最重要的是要做到精確。程序員喜歡精確。

Introduction

Anybody who has written software for public use will probably have received at least one bad bug report. Reports that say nothing ("It doesn't work!"); reports that make no sense; reports that don't give enough information; reports that give wrong information. Reports of problems that turn out to be user error; reports of problems that turn out to be the fault of somebody else's program; reports of problems that turn out to be network failures.

There's a reason why technical support is seen as a horrible job to be in, and that reason is bad bug reports. However, not all bug reports are unpleasant: I maintain free software, when I'm not earning my living, and sometimes I receive wonderfully clear, helpful, informative bug reports.

In this essay I'll try to state clearly what makes a good bug report. Ideally I would like everybody in the world to read this essay before reporting any bugs to anybody. Certainly I would like everybody who reports bugs to me to have read it.

In a nutshell, the aim of a bug report is to enable the programmer to see the program failing in front of them. You can either show them in person, or give them careful and detailed instructions on how to make it fail. If they can make it fail, they will try to gather extra information until they know the cause. If they can't make it fail, they will have to ask you to gather that information for them.

In bug reports, try to make very clear what are actual facts ("I was at the computer and this happened") and what are speculations ("I think the problem might be this"). Leave out speculations if you want to, but don't leave out facts.

When you report a bug, you are doing so because you want the bug fixed. There is no point in swearing at the programmer or being deliberately unhelpful: it may be their fault and your problem, and you might be right to be angry with them, but the bug will get fixed faster if you help them by supplying all the information they need. Remember also that if the program is free, then the author is providing it out of kindness, so if too many people are rude to them then they may stop feeling kind.

"It doesn't work."

Give the programmer some credit for basic intelligence: if the program really didn't work at all, they would probably have noticed. Since they haven't noticed, it must be working for them. Therefore, either you are doing something differently from them, or your environment is different from theirs. They need information; providing this information is the purpose of a bug report. More information is almost always better than less.

Many programs, particularly free ones, publish their list of known bugs. If you can find a list of known bugs, it's worth reading it to see if the bug you've just found is already known or not. If it's already known, it probably isn't worth reporting again, but if you think you have more information than the report in the bug list, you might want to contact the programmer anyway. They might be able to fix the bug more easily if you can give them information they didn't already have.

This essay is full of guidelines. None of them is an absolute rule. Particular programmers have particular ways they like bugs to be reported. If the program comes with its own set of bug-reporting guidelines, read them. If the guidelines that come with the program contradict the guidelines in this essay, follow the ones that come with the program!

If you are not reporting a bug but just asking for help using the program, you should state where you have already looked for the answer to your question. ("I looked in chapter 4 and section 5.2 but couldn't find anything that told me if this is possible.") This will let the programmer know where people will expect to find the answer, so they can make the documentation easier to use.

"Show me."

One of the very best ways you can report a bug is by showing it to the programmer. Stand them in front of your computer, fire up their software, and demonstrate the thing that goes wrong. Let them watch you start the machine, watch you run the software, watch how you interact with the software, and watch what the software does in response to your inputs.

They know that software like the back of their hand. They know which parts they trust, and they know which parts are likely to have faults. They know intuitively what to watch for. By the time the software does something obviously wrong, they may well have already noticed something subtly wrong earlier which might give them a clue. They can observe everything the computer does during the test run, and they can pick out the important bits for themselves.

This may not be enough. They may decide they need more information, and ask you to show them the same thing again. They may ask you to talk them through the procedure, so that they can reproduce the bug for themselves as many times as they want. They might try varying the procedure a few times, to see whether the problem occurs in only one case or in a family of related cases. If you're unlucky, they may need to sit down for a couple of hours with a set of development tools and really start investigating. But the most important thing is to have the programmer looking at the computer when it goes wrong. Once they can see the problem happening, they can usually take it from there and start trying to fix it.

"Show me how to show myself."

This is the era of the Internet. This is the era of worldwide communication. This is the era in which I can send my software to somebody in Russia at the touch of a button, and he can send me comments about it just as easily. But if he has a problem with my program, he can't have me standing in front of it while it fails. "Show me" is good when you can, but often you can't.

If you have to report a bug to a programmer who can't be present in person, the aim of the exercise is to enable them to reproduce the problem. You want the programmer to run their own copy of the program, do the same things to it, and make it fail in the same way. When they can see the problem happening in front of their eyes, then they can deal with it.

So tell them exactly what you did. If it's a graphical program, tell them which buttons you pressed and what order you pressed them in. If it's a program you run by typing a command, show them precisely what command you typed. Wherever possible, you should provide a verbatim transcript of the session, showing what commands you typed and what the computer output in response.

Give the programmer all the input you can think of. If the program reads from a file, you will probably need to send a copy of the file. If the program talks to another computer over a network, you probably can't send a copy of that computer, but you can at least say what kind of computer it is, and (if you can) what software is running on it.

"Works for me. So what goes wrong?"

If you give the programmer a long list of inputs and actions, and they fire up their own copy of the program and nothing goes wrong, then you haven't given them enough information. Possibly the fault doesn't show up on every computer; your system and theirs may differ in some way. Possibly you have misunderstood what the program is supposed to do, and you are both looking at exactly the same display but you think it's wrong and they know it's right.

So also describe what happened. Tell them exactly what you saw. Tell them why you think what you saw is wrong; better still, tell them exactly what you expected to see. If you say "and then it went wrong", you have left out some very important information.

If you saw error messages then tell the programmer, carefully and precisely, what they were. They are important! At this stage, the programmer is not trying to fix the problem: they're just trying to find it. They need to know what has gone wrong, and those error messages are the computer's best effort to tell you that. Write the errors down if you have no other easy way to remember them, but it's not worth reporting that the program generated an error unless you can also report what the error message was.

In particular, if the error message has numbers in it, do let the programmer have those numbers. Just because you can't see any meaning in them doesn't mean there isn't any. Numbers contain all kinds of information that can be read by programmers, and they are likely to contain vital clues. Numbers in error messages are there because the computer is too confused to report the error in words, but is doing the best it can to get the important information to you somehow.

At this stage, the programmer is effectively doing detective work. They don't know what's happened, and they can't get close enough to watch it happening for themselves, so they are searching for clues that might give it away. Error messages, incomprehensible strings of numbers, and even unexplained delays are all just as important as fingerprints at the scene of a crime. Keep them!

If you are using Unix, the program may have produced a core dump. Core dumps are a particularly good source of clues, so don't throw them away. On the other hand, most programmers don't like to receive huge core files by e-mail without warning, so ask before mailing one to anybody. Also, be aware that the core file contains a record of the complete state of the program: any "secrets" involved (maybe the program was handling a personal message, or dealing with confidential data) may be contained in the core file.

"So then I tried . . ."

There are a lot of things you might do when an error or bug comes up. Many of them make the problem worse. A friend of mine at school deleted all her Word documents by mistake, and before calling in any expert help, she tried reinstalling Word, and then she tried running Defrag. Neither of these helped recover her files, and between them they scrambled her disk to the extent that no Undelete program in the world would have been able to recover anything. If she'd only left it alone, she might have had a chance.

Users like this are like a mongoose backed into a corner: with its back to the wall and seeing certain death staring it in the face, it attacks frantically, because doing something has to be better than doing nothing. This is not well adapted to the type of problems computers produce.

Instead of being a mongoose, be an antelope. When an antelope is confronted with something unexpected or frightening, it freezes. It stays absolutely still and tries not to attract any attention, while it stops and thinks and works out the best thing to do. (If antelopes had a technical support line, it would be telephoning it at this point.) Then, once it has decided what the safest thing to do is, it does it.

When something goes wrong, immediately stop doing anything. Don't touch any buttons at all. Look at the screen and notice everything out of the ordinary, and remember it or write it down. Then perhaps start cautiously pressing "OK" or "Cancel", whichever seems safest. Try to develop a reflex reaction - if a computer does anything unexpected, freeze.

If you manage to get out of the problem, whether by closing down the affected program or by rebooting the computer, a good thing to do is to try to make it happen again. Programmers like problems that they can reproduce more than once. Happy programmers fix bugs faster and more efficiently.

"I think the tachyon modulation must be wrongly polarised."

It isn't only non-programmers who produce bad bug reports. Some of the worst bug reports I've ever seen come from programmers, and even from good programmers.

I worked with another programmer once, who kept finding bugs in his own code and trying to fix them. Every so often he'd hit a bug he couldn't solve, and he'd call me over to help. "What's gone wrong?" I'd ask. He would reply by telling me his current opinion of what needed to be fixed.

This worked fine when his current opinion was right. It meant he'd already done half the work and we were able to finish the job together. It was efficient and useful.

But quite often he was wrong. We would work for some time trying to figure out why some particular part of the program was producing incorrect data, and eventually we would discover that it wasn't, that we'd been investigating a perfectly good piece of code for half an hour, and that the actual problem was somewhere else.

I'm sure he wouldn't do that to a doctor. "Doctor, I need a prescription for Hydroyoyodyne." People know not to say that to a doctor: you describe the symptoms, the actual discomforts and aches and pains and rashes and fevers, and you let the doctor do the diagnosis of what the problem is and what to do about it. Otherwise the doctor dismisses you as a hypochondriac or crackpot, and quite rightly so.

It's the same with programmers. Providing your own diagnosis might be helpful sometimes, but always state the symptoms. The diagnosis is an optional extra, and not an alternative to giving the symptoms. Equally, sending a modification to the code to fix the problem is a useful addition to a bug report but not an adequate substitute for one.

If a programmer asks you for extra information, don't make it up! Somebody reported a bug to me once, and I asked him to try a command that I knew wouldn't work. The reason I asked him to try it was that I wanted to know which of two different error messages it would give. Knowing which error message came back would give a vital clue. But he didn't actually try it - he just mailed me back and said "No, that won't work". It took me some time to persuade him to try it for real.

Using your intelligence to help the programmer is fine. Even if your deductions are wrong, the programmer should be grateful that you at least tried to make their life easier. But report the symptoms as well, or you may well make their life much more difficult instead.

"That's funny, it did it a moment ago."

Say "intermittent fault" to any programmer and watch their face fall. The easy problems are the ones where performing a simple sequence of actions will cause the failure to occur. The programmer can then repeat those actions under closely observed test conditions and watch what happens in great detail. Too many problems simply don't work that way: there will be programs that fail once a week, or fail once in a blue moon, or never fail when you try them in front of the programmer but always fail when you have a deadline coming up.

Most intermittent faults are not truly intermittent. Most of them have some logic somewhere. Some might occur when the machine is running out of memory, some might occur when another program tries to modify a critical file at the wrong moment, and some might occur only in the first half of every hour! (I've actually seen one of these.)

Also, if you can reproduce the bug but the programmer can't, it could very well be that their computer and your computer are different in some way and this difference is causing the problem. I had a program once whose window curled up into a little ball in the top left corner of the screen, and sat there and sulked. But it only did it on 800x600 screens; it was fine on my 1024x768 monitor.

The programmer will want to know anything you can find out about the problem. Try it on another machine, perhaps. Try it twice or three times and see how often it fails. If it goes wrong when you're doing serious work but not when you're trying to demonstrate it, it might be long running times or large files that make it fall over. Try to remember as much detail as you can about what you were doing to it when it did fall over, and if you see any patterns, mention them. Anything you can provide has to be some help. Even if it's only probabilistic (such as "it tends to crash more often when Emacs is running"), it might not provide direct clues to the cause of the problem, but it might help the programmer reproduce it.

Most importantly, the programmer will want to be sure of whether they're dealing with a true intermittent fault or a machine-specific fault. They will want to know lots of details about your computer, so they can work out how it differs from theirs. A lot of these details will depend on the particular program, but one thing you should definitely be ready to provide is version numbers. The version number of the program itself, and the version number of the operating system, and probably the version numbers of any other programs that are involved in the problem.

"So I loaded the disk on to my Windows . . ."

Writing clearly is essential in a bug report. If the programmer can't tell what you meant, you might as well not have said anything.

I get bug reports from all around the world. Many of them are from non-native English speakers, and a lot of those apologise for their poor English. In general, the bug reports with apologies for their poor English are actually very clear and useful. All the most unclear reports come from native English speakers who assume that I will understand them even if they don't make any effort to be clear or precise.

  • Be specific. If you can do the same thing two different ways, state which one you used. "I selected Load" might mean "I clicked on Load" or "I pressed Alt-L". Say which you did. Sometimes it matters.
  • Be verbose. Give more information rather than less. If you say too much, the programmer can ignore some of it. If you say too little, they have to come back and ask more questions. One bug report I received was a single sentence; every time I asked for more information, the reporter would reply with another single sentence. It took me several weeks to get a useful amount of information, because it turned up one short sentence at a time.
  • Be careful of pronouns. Don't use words like "it", or references like "the window", when it's unclear what they mean. Consider this: "I started FooApp. It put up a warning window. I tried to close it and it crashed." It isn't clear what the user tried to close. Did they try to close the warning window, or the whole of FooApp? It makes a difference. Instead, you could say "I started FooApp, which put up a warning window. I tried to close the warning window, and FooApp crashed." This is longer and more repetitive, but also clearer and less easy to misunderstand.
  • Read what you wrote. Read the report back to yourself, and see if you think it's clear. If you have listed a sequence of actions which should produce the failure, try following them yourself, to see if you missed a step.

Summary

  • The first aim of a bug report is to let the programmer see the failure with their own eyes. If you can't be with them to make it fail in front of them, give them detailed instructions so that they can make it fail for themselves.
  • In case the first aim doesn't succeed, and the programmer can't see it failing themselves, the second aim of a bug report is to describe what went wrong. Describe everything in detail. State what you saw, and also state what you expected to see. Write down the error messages, especially if they have numbers in.
  • When your computer does something unexpected, freeze. Do nothing until you're calm, and don't do anything that you think might be dangerous.
  • By all means try to diagnose the fault yourself if you think you can, but if you do, you should still report the symptoms as well.
  • Be ready to provide extra information if the programmer needs it. If they didn't need it, they wouldn't be asking for it. They aren't being deliberately awkward. Have version numbers at your fingertips, because they will probably be needed.
  • Write clearly. Say what you mean, and make sure it can't be misinterpreted.
  • Above all, be precise. Programmers like precision.
 
發佈了22 篇原創文章 · 獲贊 2 · 訪問量 11萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章