Bugs can have a wide variety of effects, with varying levels of inconvenience to the user of the program. Some bugs have only a subtle effect on the program's functionality, and may thus lie undetected for a long time. More serious bugs may cause the program to crash or freeze. In some operating systems, such as Microsoft Windows, crashing or freezing programs may render the computer unusable until it is rebooted (see blue screen of death.) Other bugs lead to security problems; for example, a common type of bug called a buffer overflow may allow a malicious user to execute a new program that is normally not allowed to run.
The results of bugs may be extremely serious considerable. In 1962, an omitted hyphen in a Fortran program led to the loss of the Mariner 1 Venus probe, which cost over $80 million; Arthur C. Clarke dubbed this "the most expensive hyphen in history". In 1996, the European Space Agency's prototype Ariane 5 rocket was destroyed less than a minute after launch due to a bug in the on-board guidance computer, costing over US$1 billion.
The term "bug" derives from hardware engineering jargon, in which it refers to errors in hardware. The term is often (but erroneously) credited to Grace Hopper, through an anecdote where she determined the reason for a malfunction on an early electromechanical computer was an actual insect stuck between the contacts of the relays that drove the device:
Despite the colourfulness of the above anecdote, it is known that the use of the word "bug" to describe defects in mechanical systems dates back to at least the 1870s. Thomas Edison, for one, used the term in his notebooks.
Bugs are a consequence of the nature of the programming task. Some bugs arise from simple oversights made when a computer programmer writes source code carelessly. Many off-by-one errors fall into this category. Other bugs arise from unintended interactions between different parts of a computer program. This happens because computer programs are often complex, so that programmers are unable to mentally keep track of every possible way in which different parts can interact. Many race condition bugs fall into this category.
The computer software industry has put a great deal of effort into finding methods for preventing programmers from inadvertently introducing bugs while writing software. These include:
Finding and fixing bugs, or "debugging", has always been a major part of computer programming. Maurice Wilkes, an early computing pioneer, describes his realization in the late 1940s that much of the rest of his life would be spent finding mistakes in his own programs. As computer programs grow more complex, bugs become more common and difficult to fix. Often, programmers spend more time and effort finding and fixing bugs than writing new code.
Usually, the most difficult part of debugging is locating the erroneous part of the source code. Once the mistake is found, correcting it is usually easy. Programs known as debuggers exist to help programmers locate bugs. However, even with the aid of a debugger, locating bugs is something of an art.
Typically, the first step in locating a bug is finding a way to reproduce it easily. Once the bug is reproduced, the programmer can use a debugger or some other tool to monitor the execution of the program in the faulty region, and (eventually) find the problem. However, it is not always easy to reproduce bugs. Some bugs are triggered by inputs to the program which may be difficult for the programmer to re-create. Other bugs may disappear when the program is run with a debugger; these are heisenbugs (humorously named after the Heisenberg uncertainty principle.)
The following is a list of famous computer bugs: