May 29, 2012
An eluder by nature, Heisenbug, is a software bug that disappears when you attempt to study it. The name Heisenbug refers to the physicist Werner Heisenberg and his studies of quantum mechanics, the conclusion of which is that studying a system may alter its state.
Most commonly, heisenbugs are caused due to external factors and disturbances, over which a programmer has little or no control. Heisenbugs may come and go depending upon:
The compiler with which the program is being compiled. An optimizing compiler may throw the bug, but a non-optimizing compiler might not.
Using non-initialized variables in the program.
Presence of an invalid pointer in the code.
Use of external interfaces while debugging a program might also lead to a Heisenbug.
Generation of random numbers leading to table overflow.
Un-flushed cache contents get underwritten.
Analog user inputs.
However, Heisenbugs cannot be disregarded or neglected. They very much exist and need to be taken care of. It is best to eliminate all reasons that could possibly cause the random behavior of the bug and then study it.
And, How Does One Handle Heisenbugs?
It is logically impossible to fix a defect if it vanishes every time you attempt to study it. So, the first step is to make it stay. To do so, below are some pointers:
Study the frequency of the Heisenbug. Make a note of the bug as and when it occurs.
Write down all the circumstances under which the bug shows itself.
Try to reproduce the bug (with the help of a tester).
Build a profile of the bug and keep adding more information as you proceed.
Try to learn the location and cause of the bug – some bugs occur only when compiled, some occur during testing while some occur in live environments only.
Until you are sure that code alteration will fix the bug, don't do it. Because code alternation may just temporarily make the Heisenbug go away. Rather, eliminate chunks of codes by removing them and studying the effect on the bug. When a piece of code is missing, and the bug is still there, it clearly means that the piece of code is totally unrelated to the bug.
Finally, it is important not to get totally absorbed in to studying of Heisenbugs. It is rather necessary for the developers to get acquainted with debugging methods of Heisenbugs, such as CHESS, Jinx etc.
Have you ever encountered a Heisenbug in your IT career? Please share your experiences, thoughts and views for our benefit.
To experience bug tracking tool, download TestingWhiz now!