Heisenbug
{{Short description|Software bug that seems to change when debugging}}
{{for|the Linux distribution codenamed Heisenbug|Fedora Linux}}{{Distinguish|Heisenberg}}
{{Use American English|date=June 2018}}
In computer programming jargon, a heisenbug is a software bug that seems to disappear or alter its behavior when one attempts to study it.{{cite web |url=http://catb.org/jargon/html/H/heisenbug.html |title=The Jargon File: heisenbug }} The term is a pun on the name of Werner Heisenberg, the physicist who first asserted the observer effect of quantum mechanics, which states that the act of observing a system inevitably alters its state. In electronics, the traditional term is probe effect, where attaching a test probe to a device changes its behavior.
Similar terms, such as bohrbug, mandelbug,{{cite web|url=http://catb.org/jargon/html/M/mandelbug.html |title=The Jargon File: Mandelbug |publisher=Catb.org |access-date=2013-09-05}}Raymond, Eric S.; [https://books.google.com/books?id=g80P_4v4QbIC&pg=PA295&dq=mandelbug The New Hacker's Dictionary], 3rd edition, 1996Clarke, Arthur C., [http://www.google.ca/search?tbm=bks&q=%22The+Mandelbug.+Get+Ada+to+explain+it+to+you+someday.%22 The Ghost from the Grand Banks], Bantam Books, 1990 hindenbug, and schrödinbug{{cite web|url=http://www.catb.org/jargon/html/S/schroedinbug.html |title=The Jargon File: Schroedinbug |publisher=Catb.org |access-date=2013-09-05}}Raymond, Eric S.; [https://books.google.com/books?id=g80P_4v4QbIC&pg=PA397&dq=schroedinbug The New Hacker's Dictionary], 3rd edition, 1996 (see the section on related terms) have been occasionally proposed for other kinds of unusual software bugs, sometimes in jest.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: Grottke, Michael; and Trivedi, Kishor S.; Software Faults, Software Aging and Software Rejuvenation, Journal of the Reliability Engineering Association of Japan, Vol. 27, No. 7, pp. 425–438, 2005.Grottke, Michael; and Trivedi, Kishor S.; [https://web.archive.org/web/20100327174716/http://www.computer.org/portal/web/csdl/doi/10.1109/MC.2007.55 Fighting Bugs: Remove, Retry, Replicate, and Rejuvenate], IEEE Computer vol. 40, no. 2 (February 2007), pp. 107–109
Examples
Heisenbugs occur because common attempts to debug a program, such as inserting output statements or running it with a debugger, usually have the side-effect of altering the behavior of the program in subtle ways, such as changing 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{{Citation needed|date=March 2024}}. Similarly, heisenbugs may be caused by side-effects in test expressions used in runtime assertions in languages such as C and C++, where the test expression is not evaluated when assertions are turned off in production code using the NDEBUG
macro.
Other common causes of heisenbugs are using the value of a non-initialized variable (which may change its address or initial value during debugging), or following an invalid pointer (which may point to a different place when debugging). Debuggers also commonly allow the use of breakpoints or provide 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.[http://debuggers.co/java/enterprise/2014/06/17/Kyle-Harr.html "Java toString() override with initialization as a side effect"] {{webarchive|url=https://web.archive.org/web/20141230005029/http://debuggers.co/java/enterprise/2014/06/17/Kyle-Harr.html |date=2014-12-30 }}
End-Users can experience a heisenbug when the act of making a screenshot of the heisenbug for observation fixes the heisenbug and the screenshot shows a perfectly working state. This effect can happen when complex stacks of software work together, for example a web browser using a hardware graphic card acceleration which causes rendering errors on the physical screen that do not show on a screenshot.
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.
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,CATB.org, [http://www.catb.org/jargon/html/P/phase-of-the-moon.html "phase of the moon"] 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, a well-documented phenomenon known as single event effects.
Related terms
A bohrbug, by way of contrast, is a "good, solid bug". Like the deterministic Bohr atom model, they do not change their behavior and are relatively easily detected.Goshgarian, Gary; 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 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. The term also refers to a bug that exhibits fractal behavior (that is, self-similarity) by revealing more bugs (the deeper a developer goes into the code to fix it the more bugs they find).{{citation needed|date=August 2016}}
A schrödinbug or schroedinbug (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.
A hindenbug{{cite web |url=http://c2.com/cgi/wiki?HindenBug | title=Hinden Bug }}{{better source|date=August 2016}} (named after the Hindenburg disaster) is a bug with catastrophic behavior.
A higgs-bugson{{cite web| url=https://blog.codinghorror.com/new-programming-jargon/ | title=New Programming Jargon| date=20 July 2012}}{{cite web | url=http://www.businessinsider.com/20-hilarious-programming-jargon-phrases-you-should-know-when-talking-to-engineers-2012-7 | title=20 Hilarious Programming Jargon Phrases You Should Use When Talking to Engineers| website=Business Insider}} (named after the Higgs boson particle) is a bug that is predicted to exist based upon other observed conditions (most commonly, vaguely related log entries and anecdotal user reports) but is difficult, if not impossible, to artificially reproduce in a development or test environment. The term may also refer to a bug that is obvious in the code (mathematically proven), but which cannot be seen in execution (yet difficult or impossible to actually find in existence).
Etymology
The earliest known appearance is from 1983, in an ACM publication.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, [http://www.google.ca/search?tbm=bks&q=an+instance+of+such+a+bug+was+called+a+%22Heisenbug%22+by+one+participant Google Books search]:
{{Quote|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 LeBlanc, Richard J.; Robbins, Arnold D.; Event-Driven Monitoring of Distributed Programs, in Proceedings of the IEEE 5th International Conference on Distributed Computing Systems (ICDCS), IEEE Computer Society, Computer Society Press, 1985, pp. 515-522 [http://www.google.ca/search?tbm=bks&q=This+the+Heisenberg+Uncertainty+Principle+as+applied+to+Debugging%2C+sometimes+called+the+%22Heisenbug%22+Principle+%5BACM83%5D Google Books search]:
{{Quote|This the Heisenberg Uncertainty Principle as applied to Debugging, sometimes called the "Heisenbug" Principle [ACM83].}}{{Clear}}
The term was used in 1985 by Jim Gray, in a paper about software failures,{{cite web |last=Gray |first=Jim |url=http://citeseer.ist.psu.edu/viewdoc/summary?doi=10.1.1.59.6561 |title=Why Do Computers Stop And What Can Be Done About It? |year=1985 |publisher=Tandem Computers |work=Technical Report 85.7 }} and is sometimes mistakenly attributed to him because of this publication. It was used in 1986 by Jonathan Clark and Zhahai Stewart on the mailing list (later Usenet news group) comp.risks.(16 December 1986) [https://groups.google.com/group/mod.risks/browse_thread/thread/cc68771824a79d3f RISKS DIGEST 4.30] - (23 December 1986) [https://groups.google.com/group/mod.risks/browse_thread/thread/83a6ad844eda93e0/5e061e6da0c2dbfc?lnk=st&q=heisenbug&rnum=896#5e061e6da0c2dbfc RISKS DIGEST 4.34], moderated by Peter G. Neumann
Bruce Lindsay, a researcher at IBM, affirmed in a 2004 ACM Queue interview that he was present when the Heisenbug was originally defined,{{cite web|url=http://queue.acm.org/detail.cfm?id=1036486 |title="A Conversation with Bruce Lindsay", ACM Queue vol. 2, no. 8 - November 2004 |publisher=Queue.acm.org |access-date=2013-09-05}} but did not state when this occurred.
Resolution
Heisenbugs are difficult to identify and fix; often attempting to resolve them leads to further unexpected behavior. Because the problem manifests as the result of a separate, underpinning bug, the behavior can be hard to predict and analyze during debugging. Overall the number of heisenbugs identified should decrease as a piece of software matures.{{Cite book|title=Reliable distributed systems : technologies, Web services, and applications|last=P.|first=Birman, Kenneth|date=2005|publisher=Springer|isbn=0387276017|location=New York|oclc=225378026}}
See also
- Cargo cult programming
- Jinx Debugger—a tool that automatically explores executions likely to expose Heisenbugs
- Memory debugger
References
{{Reflist|30em}}
External links
- [http://sourceware.org/gdb/talks/esc-west-1999/ The Heisenberg Debugging Technology]
- [http://catb.org/jargon/html/magic-story.html A Story About Magic]
- [https://bugs.launchpad.net/ubuntu/+source/cupsys/+bug/255161/comments/28 OpenOffice won't print on Tuesdays], a heisenbug that took almost nine months to solve.
{{DEFAULTSORT:Unusual Software Bug}}