A bug, also referred to as a software bug, is an error or flaw in a computer program that may prevent it from working correctly or produce an incorrect or unintended result.
Bugs arise from mistakes made by humans in designing programs and writing their source code. Source code, also referred to as code, is the version of software (usually an application program or an operating system) as it is originally written (i.e., typed into a computer) by programmers using any of numerous programming languages, some of the most popular of which are C, C++, Java, Perl, PHP, Python and Tcl/Tk.
It is likely that there are bugs in virtually all useful computer programs. This is because of (1) the huge number of lines of code required for such programs, (2) the complexity of programming and the consequent ease of making errors and (3) the difficulty of detecting some types of errors. For example, a modern operating system typically contains several million lines of code (e.g., roughly 40 million for Microsoft Windows XP).
As programs continue to grow longer and more complex, bugs are becoming even more common and more difficult to find. Thus programmers now often devote more time and effort to finding and fixing bugs than to writing new code.
The frequency of bugs (e.g., the average number of bugs per million lines of code) can vary greatly according to the program. Well-written programs typically have few if any bugs that prevent them from functioning as intended nearly all of the time.
A program that contains a large number of bugs and/or bugs that seriously interfere with its functionality is said to be buggy. Reports about bugs in a program are referred to as bug reports or change requests.
Bugs can have a wide variety of effects, with varying levels of inconvenience to the users of a program. Some bugs affect a program's functionality only under very unusual circumstances and/or have only a subtle effect on a program's functionality, and they can thus lie undetected for a long time. More serious bugs can cause the program to crash or freeze in relatively common situations.
In some operating systems, such as the Microsoft Windows systems, a single crashing or freezing application program can make the entire computer unusable until it is rebooted (i.e., restarted). This can be not only inconvenient but also very costly for a large organization. Linux and other Unix-like operating systems are designed from the ground up so that bugs in application programs will usually not affect other programs or require the system to be rebooted.
Some bugs can result in security problems. One of the most common types is a buffer overflow, which can permit a malicious user or intruder to enter a system and execute programs that ordinary users are not normally allowed to run. A buffer overflow occurs any time a program writes more information into the buffer than there is memory space allocated for it. A buffer is a portion of memory that is set aside as a temporary holding place to store data, often before it is sent to or received from an external device.
Some bugs arise from unintended interactions between different parts of a program. This happens because programs are typically very complicated and thus programmers cannot visualize every possible way in which different parts could interact. Race condition bugs often fall into this category. A race condition occurs when the final state of a system depends on the order in which independently scheduled sequences of instructions are executed.
The results of bugs can be extremely serious. For example, in 1996, the European Space Agency's Ariane 5 rocket, which was valued at approximately US$500 million, exploded 40 seconds after launching due to a bug in its on-board guidance software1.
The software industry has devoted much effort to finding methods for reducing the number of bugs. Among the approaches that are being used are improved design of programming languages (e.g., the elimination of pointers, which are a major cause of programming errors), better compilers (which can detect more types of errors) and improved testing techniques.
The use of the term bug to describe inexplicable defects has been a part of engineering jargon for well in excess of a century. For example, Thomas Edison used it in a letter to an associate in 1878. The term may have first been used in a computer context around 1947 by Grace Hopper, an early computer pioneer, who traced an error made by a computer to an actual insect stuck between the contacts of an electrical relay in the system.
Created August 20, 2005.