Heisenbug
Heisenbug is a whimsical computer programming jargon term for a software bug that seems to disappear when one attempts to study it.[1] The term is a pun on the name of Werner Heisenberg, the physicist who is commonly associated to the observer effect of quantum mechanics, which states that the act of observing a system inevitably alters its state.
Similar terms, such as bohrbug, mandelbug[2], and schrödinbug[3] have been occasionally proposed for other kinds of unusual software bugs, sometimes in jest[4][5]; however (unlike "heisenbug") they are not widely known or used[citation needed].
Contents |
[edit] Examples
Heisenbugs occur because common attempts to debug a program, such as inserting output statements or running it in a debugger, usually modify the code, change the memory addresses of variables and the timing of its execution.
One common example of a heisenbug is a bug that appears when the program is compiled with an optimizing compiler, but not when the same program is compiled without optimization (as is often done for the purpose of examining it with a debugger). While debugging, values that an optimized program would normally keep in registers are often pushed to main memory. This may affect, for instance, the result of floating-point comparisons, since the value in memory may have smaller range and accuracy than the value in the register. In these cases, the bug is in the optimizing compiler and not in the program.[citation needed]
Other common causes of heisenbugs are using the value of a non-initialized variable (which may change its address and/or initial value during debugging), or following an invalid pointer (which may point to a different place when debugging). Debuggers also commonly provide watches or other user interfaces that cause additional source code (such as property accessors) to be executed stealthily, which can, in turn, change the state of the program.
Time can also be a factor in heisenbugs, particularly with multi-threaded applications. Executing a program under control of a debugger can change the execution timing of the program as compared to normal execution. Time-sensitive bugs such as race conditions may not occur when the program is slowed down by single-stepping source lines in the debugger. This is particularly true when the behavior involves interaction with an entity not under the control of a debugger, such as when debugging network packet processing between two machines and only one is under debugger control.
In general, programs that exhibit time-dependent behavior are vulnerable to time-dependent failures. These could occur during a certain part of a scheduled process, or at special times, such as on leap days or when a process crosses a daylight saving time, day, month, year, or century boundary (as with the Year 2000 problem).
Heisenbugs can be viewed as instances of the observer effect in information technology. Frustrated programmers may humorously blame a heisenbug on the phase of the moon[6], or (if it has occurred only once) may explain it away as a soft error due to alpha particles or cosmic rays affecting the hardware.
[edit] Related terms
A bohrbug, by opposition, is a "good, solid bug". Like the deterministic Bohr atom model, they don't change their behavior and are relatively easily detected.[7][8]
A mandelbug (named after Benoît Mandelbrot's fractal) is a bug whose causes are so complex it defies repair, or makes its behavior appear chaotic or even non-deterministic.[9]
A schrödinbug (named after Erwin Schrödinger and his thought experiment) is a bug that manifests itself in running software after a programmer notices that the code should never have worked in the first place.[9]
[edit] History of the term
The term was used in 1985 by Jim Gray, in a paper about software failures[10] (and is sometimes mistakenly attributed to him because of this publication) and also in 1986 by Jonathan Clark and Zhahai Stewart on the mailing list (later Usenet news group) comp.risks.[11]
Bruce Lindsay, a researcher at IBM, affirmed in a 2004 ACM Queue interview that he was present when the Heisenbug was originally defined.[12]
An earlier appearance in ACM publications is from 1983.[13]
[edit] See also
- Cargo cult programming
- CHESS—a tool for detecting and reproducing Heisenbugs (Windows)
- Memory debugger
- Jinx—a tool that automatically explores executions likely to expose Heisenbugs
[edit] References
- ^ "The Jargon File: heisenbug". http://catb.org/jargon/html/H/heisenbug.html.
- ^ The Jargon File: Mandelbug
- ^ The Jargon File: Schroedinbug
- ^ The following article investigates the various definitions of bohrbug, mandelbug and heisenbug proposed in the literature, as well as the statements made about the relationships between these fault types: M. Grottke and K. S. Trivedi, Software Faults, Software Aging and Software Rejuvenation. Journal of the Reliability Engineering Association of Japan, Vol. 27, No. 7, pp. 425-438, 2005.
- ^ IEEE Computer vol. 40, no. 2 - February 2007
- ^ CATB.org, "phase of the moon"
- ^ Gary Goshgarian, Exploring Language, HarperCollins College Publishers, 1995
- ^ "Such transient software failures have been given the whimsical name “Heisenbug” because they disappear when reexamined. By contrast, “Bohrbugs” are good solid bugs." (IEEE Computer Group News, Volume 24, Numbers 7–12, 1991)
- ^ a b CSO, Vol. 5, No. 5 (May 2006)
- ^ "Why Do Computers Stop And What Can Be Done About It?". 1985. http://citeseer.ist.psu.edu/gray85why.html.
- ^ (16 December 1986) RISKS DIGEST 4.30 - (23 December 1986) RISKS DIGEST 4.34, moderated by Peter G. Neumann
- ^ "A Conversation with Bruce Lindsay", ACM Queue vol. 2, no. 8 - November 2004
- ^ Proceedings of the ACM SIGSOFT/SIGPLAN Software Engineering Symposium on High-Level Debugging, Pacific Grove, California, March 20-23, 1983, Association for Computing Machinery, 1983, Google Books search:
This is the Heisenberg Uncertainty Principle as applied to debugging (an instance of such a bug was called a "Heisenbug" by one participant.
“”
Also cited in Proceedings, IEEE Computer Society, Computer Society Press, 1985, Google Books search:
This the Heisenberg Uncertainty Principle as applied to Debugging, sometimes called the "Heisenbug" Principle [ACM83].
“”