HOME

TheInfoList



OR:

In
computer programming Computer programming or coding is the composition of sequences of instructions, called computer program, programs, that computers can follow to perform tasks. It involves designing and implementing algorithms, step-by-step specifications of proc ...
jargon, a heisenbug is a
software bug A software bug is a design defect ( bug) in computer software. A computer program with many or serious bugs may be described as ''buggy''. The effects of a software bug range from minor (such as a misspelled word in the user interface) to sev ...
that seems to disappear or alter its behavior when one attempts to study it. The term is a pun on the name of
Werner Heisenberg Werner Karl Heisenberg (; ; 5 December 1901 – 1 February 1976) was a German theoretical physicist, one of the main pioneers of the theory of quantum mechanics and a principal scientist in the German nuclear program during World War II. He pub ...
, the
physicist A physicist is a scientist who specializes in the field of physics, which encompasses the interactions of matter and energy at all length and time scales in the physical universe. Physicists generally are interested in the root or ultimate cau ...
who first asserted the observer effect of
quantum mechanics Quantum mechanics is the fundamental physical Scientific theory, theory that describes the behavior of matter and of light; its unusual characteristics typically occur at and below the scale of atoms. Reprinted, Addison-Wesley, 1989, It is ...
, 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'', ''hindenbug'', and ''schrödinbug'' (see the section on related terms) have been occasionally proposed for other kinds of unusual software bugs, sometimes in jest.


Examples

Heisenbugs occur because common attempts to debug a program, such as inserting output statements or
running Running is a method of terrestrial locomotion by which humans and other animals move quickly on foot. Running is a gait with an aerial phase in which all feet are above the ground (though there are exceptions). This is in contrast to walkin ...
it with a
debugger A debugger is a computer program used to test and debug other programs (the "target" programs). Common features of debuggers include the ability to run or halt the target program using breakpoints, step through code line by line, and display ...
, 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 In computing, a compiler is a computer program that Translator (computing), translates computer code written in one programming language (the ''source'' language) into another language (the ''target'' language). The name "compiler" is primaril ...
, 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 In computing, floating-point arithmetic (FP) is arithmetic on subsets of real numbers formed by a ''significand'' (a Sign (mathematics), signed sequence of a fixed number of digits in some Radix, base) multiplied by an integer power of that ba ...
comparisons, since the value in memory may have smaller range and accuracy than the value in the register. 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
breakpoint In software development, a breakpoint is an intentional stopping or pausing place in a computer program, program, put in place for debugging purposes. It is also sometimes simply referred to as a pause. More generally, a breakpoint is a means o ...
s or provide other user interfaces that cause additional
source code In computing, source code, or simply code or source, is a plain text computer program written in a programming language. A programmer writes the human readable source code to control the behavior of a computer. Since a computer, at base, only ...
(such as property accessors) to be executed stealthily, which can, in turn, change the state of the program. 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 condition A race condition or race hazard is the condition of an electronics, software, or other system where the system's substantive behavior is dependent on the sequence or timing of other uncontrollable events, leading to unexpected or inconsistent ...
s, 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, or (if it has occurred only once) may explain it away as a soft error due to alpha particles or
cosmic ray Cosmic rays or astroparticles are high-energy particles or clusters of particles (primarily represented by protons or atomic nuclei) that move through space at nearly the speed of light. They originate from the Sun, from outside of the ...
s 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 In atomic physics, the Bohr model or Rutherford–Bohr model was a model of the atom that incorporated some early quantum concepts. Developed from 1911 to 1918 by Niels Bohr and building on Ernest Rutherford's nuclear Rutherford model, model, i ...
, they do not change their behavior and are relatively easily detected. A ''mandelbug'' (named after
Benoît Mandelbrot Benoit B. Mandelbrot (20 November 1924 – 14 October 2010) was a Polish-born French-American mathematician and polymath with broad interests in the practical sciences, especially regarding what he labeled as "the art of #Fractals and the ...
's
fractal In mathematics, a fractal is a Shape, geometric shape containing detailed structure at arbitrarily small scales, usually having a fractal dimension strictly exceeding the topological dimension. Many fractals appear similar at various scale ...
) 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). A ''schrödinbug'' or ''schroedinbug'' (named after
Erwin Schrödinger Erwin Rudolf Josef Alexander Schrödinger ( ; ; 12 August 1887 – 4 January 1961), sometimes written as or , was an Austrian-Irish theoretical physicist who developed fundamental results in quantum field theory, quantum theory. In particul ...
and his
thought experiment A thought experiment is an imaginary scenario that is meant to elucidate or test an argument or theory. It is often an experiment that would be hard, impossible, or unethical to actually perform. It can also be an abstract hypothetical that is ...
) 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'' (named after the Hindenburg disaster) is a bug with catastrophic behavior. A ''higgs-bugson'' (named after the
Higgs boson The Higgs boson, sometimes called the Higgs particle, is an elementary particle in the Standard Model of particle physics produced by the excited state, quantum excitation of the Higgs field, one of the field (physics), fields in particl ...
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. The term was used in 1985 by Jim Gray, in a paper about software failures, 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 Usenet (), a portmanteau of User's Network, is a worldwide distributed discussion system available on computers. It was developed from the general-purpose UUCP, Unix-to-Unix Copy (UUCP) dial-up network architecture. Tom Truscott and Jim Elli ...
news group) comp.risks.(16 December 1986
RISKS DIGEST 4.30
- (23 December 1986
RISKS DIGEST 4.34
moderated by Peter G. Neumann
Bruce Lindsay, a researcher at
IBM International Business Machines Corporation (using the trademark IBM), nicknamed Big Blue, is an American Multinational corporation, multinational technology company headquartered in Armonk, New York, and present in over 175 countries. It is ...
, affirmed in a 2004
ACM Queue ACM ''Queue'' (stylized ''acmqueue'') is a bimonthly computer magazine, targeted to software engineer Software engineering is a branch of both computer science and engineering focused on designing, developing, testing, and maintaining softwar ...
interview that he was present when the Heisenbug was originally defined, 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.


See also

* Cargo cult programming * Jinx Debugger—a tool that automatically explores executions likely to expose Heisenbugs * Memory debugger


References


External links


The Heisenberg Debugging Technology



OpenOffice won't print on Tuesdays
a heisenbug that took almost nine months to solve. {{DEFAULTSORT:Unusual Software Bug Software bugs Debugging Software testing Computer programming folklore Software engineering folklore