Software bug: Difference between revisions

Content deleted Content added
m Terminology: removed word "true"
Tag: Reverted
m Static analysis: remove user name comment
 
(27 intermediate revisions by 15 users not shown)
Line 13:
 
== History ==
{{see|Bug (engineering)#History}}
{{see|Bug (engineering)#History}}The origin of the term "bug" in engineering contexts dates back to at least the 19th century. Thomas Edison, in an 1878 letter, referred to minor faults in his inventions as "bugs," indicating early usage of the term to describe technical issues.
 
In computing, a notable anecdote involves computer scientist Grace Hopper. While working on the Harvard Mark II computer in 1947, her team found a moth causing a malfunction by being stuck in a relay. They documented the incident as the "first actual case of a bug being found." Although the term "bug" was already in use, this event popularized its association with computer glitches.
 
== Terminology ==
Line 26 ⟶ 24:
|date=December 31, 1990
|isbn=978-0-7381-0391-4
|doi=10.1109/IEEESTD.1990.101064}}</ref>{{rp|31}}anomaly,<ref name=ieeeGlossary/>{{rp|10}} fault,<ref name=ieeeGlossary/>{{rp|31}} failure,<ref name=ieeeGlossary/>{{rp|31}} error,<ref name=ieeeGlossary/>{{rp|31}} exception,<ref name=ieeeGlossary/>{{rp|31}} crash,<ref name=ieeeGlossary/>{{rp|22}} glitch, bug,<ref name=ieeeGlossary/>{{rp|14}} defect, incident,<ref name=ieeeGlossary/>{{rp|39}} or side effect.
|doi=10.1109/IEEESTD.1990.101064}}</ref>{{rp|31}}
anomaly,<ref name=ieeeGlossary/>{{rp|10}}
fault,<ref name=ieeeGlossary/>{{rp|31}}
failure,<ref name=ieeeGlossary/>{{rp|31}}
error,<ref name=ieeeGlossary/>{{rp|31}}
exception,<ref name=ieeeGlossary/>{{rp|31}}
crash,<ref name=ieeeGlossary/>{{rp|22}}
glitch,
bug,<ref name=ieeeGlossary/>{{rp|14}}
defect,
incident,<ref name=ieeeGlossary/>{{rp|39}}
or side effect.
 
== Controversy Examples==
Software bugs have been linked to disasters.
* Software bugs in the [[Therac-25|Therac-25 radiation therapy machine]] were directly responsible for patient deaths in the 1980s.<ref name="Raj">{{cite journal | last1 = Leveson | first1 = Nancy G. | author-link1 = Nancy G. Leveson | last2 = Turner | first2 = Clark S. | date = 1993-07-01 | title = An Investigation of the Therac-25 Accidents | journal = [[Computer (magazine)|Computer]] | volume = 26 | issue = 7 | pages = 18{{hyphen}}41 | publisher = [[IEEE Computer Society]] | doi = 10.1109/MC.1993.274940 | eissn = 1558-0814 | issn = 0018-9162 | lccn = 74648480 | s2cid = 9691171 | oclc = 2240099 | url = https://escholarship.org/uc/item/5dr206s3 | df = dmy-all}}</ref>
* In 1996, the [[European Space Agency]]'s US$1&nbsp;billion prototype [[Ariane flight V88|Ariane 5 rocket was destroyed]] less than a minute after launch due to a bug in the on-board guidance computer program.<ref>{{cite journal
|title= ARIANE 5 Flight 501 Failure Report by the Inquiry Board
|date=July 23, 1996
|issue=333–1996
|journal=[[The European Space Agency]]
|series=Ariane 501 Inquiry Board report
|url=https://www.esa.int/Newsroom/Press_Releases/Ariane_501_-_Presentation_of_Inquiry_Board_report
}}</ref>
* In 1994, an [[1994 Scotland RAF Chinook crash|RAF Chinook helicopter crashed]], killing 29; was initially blamed on pilot error, but was later thought to have been caused by a software bug in the [[FADEC|engine-control computer]].<ref>{{cite journal
|author= [[Simon Rogerson]]
|url= http://www.ccsr.cse.dmu.ac.uk/resources/general/ethicol/Ecv12no2.html
|title=The Chinook Helicopter Disaster
|journal=IMIS Journal
|volume=212
|issue=2
|date=April 2002
|url-status= dead
|archive-url=http://web.archive.org/web/19930915000000/http://www.ccsr.cse.dmu.ac.uk/resources/general/ethicol/Ecv12no2.html
|archive-date=September 15, 1993
|access-date=May 27, 2024}} [https://www5.in.tum.de/~huckle/chinook_software.pdf Alt URL]</ref>
* Buggy software caused the early 21st century [[British Post Office scandal]].<ref name=beeb182>{{Cite news |title=Post Office scandal ruined lives, inquiry hears |author=<!--not stated--> |work=BBC News |date=14 February 2022 |url= https://www.bbc.co.uk/news/business-60374182}}</ref>
 
== Controversy ==
Sometimes the use of ''bug'' to describe the behavior of software is contentious due to perception. Some suggest that the term should be abandoned; replaced with ''defect'' or ''error''.
 
Sometimes the use of ''bug'' to describe the behavior of software is contentious due to perception. Some contendsuggest that the term should be abandoned; contending that ''bug'' implies that the defect arose on its own and push to use ''defect'' instead since it more clearly connotatesindicates they are caused by a human.<ref>{{cite journalweb
|website=News at SEI
|publisher=[[Software Engineering Institute]]
|title=News at SEI September 1999Bugs or Defects?
|date=SeptemberApril 1, 1999
|first=Watts S.
|journal=SEI Interactive
|last=Humphrey
|volume=2
|author-link=Watts Humphrey
|issue=3
|url=https://insights.sei.cmu.edu/documents/2648/1999_102_001_413932.pdf
|___location=[[Carnegie Mellon University]]
|at=page 73 of 154 in PDF file
|url=https://insights.sei.cmu.edu/library/news-at-sei-september-1999}}</ref>
|access-date=2025-02-02
|archive-url=https://web.archive.org/web/20231015130719/https://insights.sei.cmu.edu/documents/2648/1999_102_001_413932.pdf
|archive-date=2023-10-15
|url-status=live
|url=}} (linked from [https://insights.sei.cmu.edu/library/news-at-sei-september1999-archive/ News at SEI 1999}} Archive])</ref>
 
Some contend that ''bug'' may be used to [[coverup|cover up]] an intentional design decision. In 2011, after receiving scrutiny from US Senator [[Al Franken]] for recording and storing users' locations in unencrypted files,<ref>{{cite journal
|author=Gregg Keizer
|title=Apple faces questions from Congress about iPhone tracking
Line 82 ⟶ 98:
 
Newer [[programming language]]s tend to be designed to prevent common bugs based on vulnerabilities of existing languages. Lessons learned from older languages such as [[BASIC]] and [[C (programming language)|C]] are used to inform the design of later languages such as [[C Sharp (programming language)|C#]] and [[Rust (programming language)|Rust]].
 
A [[compiled]] language allows for detecting some typos (such as a misspelled identifier) before [[Runtime (program lifecycle phase)|runtime]] which is earlier in the [[software development process]] than for an [[Interpreter (computing)|interpreted]] language.
 
Languages may include features such as a static [[type system]], restricted [[namespace]]s and [[modular programming]]. For example, for a typed, compiled language (like [[C (programming language)|C]]):
Line 89 ⟶ 107:
is syntactically correct, but fails type checking since the right side, a string, cannot be assigned to a float variable. Compilation fails {{endash}} forcing this defect to be fixed before development progress can resume. With an interpreted language, a failure would not occur until later at runtime.
 
Some languages exclude features that easily lead to bugs, at the expense of slower performance {{endash}} the principle being that it is usually better to write simpler, slower correct code than complicated, buggy code. For example, the [[Java (programming language)|Java]] does not support [[pointer (computer programming)|pointer]] arithmetic which iscan generallybe very fast, but ismay consideredlead dangerous;to relatively[[memory easycorruption]] toor cause[[Segmentation afault|segmentation majorfaults]] bug.if not used with great caution.
 
Some languages include features that add runtime overhead in order to prevent somecommon bugs. For example, many languages include runtime [[bounds checking]] and a way to handlerecover from out-of-bounds conditionserrors instead of crashing.
 
A [[compiled]] language allows for detecting some typos (such as a misspelled identifier) before [[Runtime (program lifecycle phase)|runtime]] which is earlier in the [[software development process]] than for an [[Interpreter (computing)|interpreted]] language.
 
=== Techniques ===
 
Programming techniques such as [[programming style|Style guidelines]] and [[defensive programming]] arecan intendedprevent easy-to-miss preventtypographical errors (typos).
 
For example, amost bug[[List_of_C-family_programming_languages|C-family mayprogramming belanguages]] causedallow bythe aomission relativelyof minor,braces typographicalaround erroran (typo)instruction inblock theif code.there's Foronly a single instruction. example,The thisfollowing code executes function {{code|foo}} only if {{code|condition}} is true.:
 
if (condition)
foo();
 
But this code always executes {{code|foo}}:
 
if (condition);
foo();
 
Using braces - even if they're not strictly required - reliably prevents this error:
A convention that tends to prevent this particular issue is to require braces for a block even if it has just one line.
 
if (condition) {
foo();
}
 
Enforcement of conventions may be manual (i.e. via [[code review]]) or via automated tools such as [[Lint_(software)|linters]].
 
=== Specification ===
 
Some{{who?|date=May 2025}} contend that writing a [[program specification]], which states the intended behavior of a program, can prevent bugs. Others{{who?|date=May 2025}}, however, contend that formal specifications are impractical for anything but the shortest programs, because of problems of [[combinatorial explosion]] and [[Nondeterministic algorithm|indeterminacy]].
 
Some contend that formal specifications are impractical for anything but the shortest programs, because of problems of [[combinatorial explosion]] and [[Nondeterministic algorithm|indeterminacy]].
 
=== Software testing ===
 
One goal of [[software testing]] is to find bugs. Measurements during testing can provide an estimate of the number of likely bugs remaining. This becomes more reliable the longer a product is tested and developed.{{citation needed|date=February 2017}}
One goal of [[software testing]] is to find bugs.
 
Measurements during testing can provide an estimate of the number of likely bugs remaining. This becomes more reliable the longer a product is tested and developed.{{citation needed|date=February 2017}}
 
=== Agile practices ===
Line 131 ⟶ 145:
[[Agile software development]] may involve frequent software releases with relatively small changes. Defects are revealed by user feedback.
 
With [[test-driven development]] (TDD), [[unit test]]s are written while writing the production code, and the production code is not considered complete until all tests have been written and complete successfully.
 
=== Static analysis ===
 
Tools for [[static code analysis]] help developers by inspecting the program text beyond the compiler's capabilities to spot potential problems. Although in general the problem of finding all programming errors given a specification is not solvable (see [[halting problem]]), these tools exploit the fact that human programmers tend to make certain kinds of simple mistakes often when writing software.
 
=== Instrumentation ===
Line 194 ⟶ 208:
=== Severity ===
 
''Severity'' is a measure of impact the bug has.<ref>{{Cite journal|last1=Soleimani Neysiani|first1=Behzad|last2=Babamir|first2=Seyed Morteza|last3=Aritsugi|first3=Masayoshi|date=2020-10-01|title=Efficient feature extraction model for validation performance improvement of duplicate bug report detection in software bug triage systems|url=https://linkinghub.elsevier.com/retrieve/pii/S0950584920301117|journal=Information and Software Technology|language=en|volume=126|pages=106344|doi=10.1016/j.infsof.2020.106344|s2cid=219733047|url-access=subscription}}</ref> This impact may be data loss, financial, loss of goodwill and wasted effort. Severity levels are not standardized, but differ by context such as industry and tracking tool. For example, a crash in a video game has a different impact than a crash in a bank server. Severity levels might be ''crash or hang'', ''no workaround'' (user cannot accomplish a task), ''has workaround'' (user can still accomplish the task), ''visual defect'' (a misspelling for example), or ''documentation error''. Another example set of severities: ''critical'', ''high'', ''low'', ''blocker'', ''trivial''.<ref>{{cite web|url=http://www.bugzilla.org/docs/4.4/en/html/bug_page.html|title=5.3. Anatomy of a Bug|work=bugzilla.org|url-status=live|archive-url=https://web.archive.org/web/20130523121753/http://www.bugzilla.org/docs/4.4/en/html/bug_page.html|archive-date=May 23, 2013}}</ref> The severity of a bug may be a separate category to its priority for fixing, or the two may be quantified and managed separately.
 
{{anchor|Show stopper|Showstopper|Showstopper bug}}A bug severe enough to delay the release of the product is called a ''show stopper''.<ref name="DoD_Glossary1989">{{Cite encyclopedia |title=Show stopper |encyclopedia=Glossary: defense acquisition acronyms and terms |year=1989 |publisher=Department of Defense, [[Defense Systems Management College]] |___location=Fort Belvoir, Virginia|url=https://hdl.handle.net/2027/mdp.39015061290758?urlappend=%3Bseq=163 |editor-last=Jones |editor-first=Wilbur D. Jr. |edition=4 |page=123 |hdl=2027/mdp.39015061290758?urlappend=%3Bseq=163 |language=en|via=Hathitrust}}</ref><ref name="Zachary1994">{{Cite book |title=Show-stopper!: the breakneck race to create Windows NT and the next generation at Microsoft |last=Zachary |first=G. Pascal |publisher=[[Free Press (publisher)|The Free Press]] |year=1994 |isbn=0029356717 |___location=New York |page=158 |language=en |url=https://archive.org/details/showstopperbreak00zach/page/158/mode/1up?q=%22showstopper+bug%22 |url-access=registration |via=archive.org}}</ref>
Line 236 ⟶ 250:
=== Cost ===
 
In 1994, NASA's [[Goddard Space Flight Center]] managed to reduce their average number of errors from 4.5 per 10001,000 lines of code ([[Source lines of code|SLOC]]) down to 1 per 1000 SLOC.<ref name=NASA1994>{{cite journal
|journal=Software Engineering Laboratory Series
|title=An Overview of the Software Engineering Laboratory
Line 250 ⟶ 264:
|series=NASA Office of Chief Engineer Technical Excellence Program
|url= https://www.nasa.gov/wp-content/uploads/2015/04/418878main_fswc_final_report.pdf
}}</ref> Some projects even attained zero defects: the [[firmware]] in the [[IBM Wheelwriter]] typewriter which consists of 63,000 SLOC, and the [[Space Shuttle]] software with 500,000 SLOC.<ref name="CobbMills1990" />
}}</ref>
Some projects even attained zero defects: the [[firmware]] in the [[IBM Wheelwriter]] typewriter which consists of 63,000 SLOC, and the [[Space Shuttle]] software with 500,000 SLOC.<ref name="CobbMills1990" />
 
=== Benchmark ===
Line 257 ⟶ 270:
To facilitate reproducible research on testing and debugging, researchers use curated benchmarks of bugs:
* the Siemens benchmark
* ManyBugs<ref name="Le GouesHoltschulte2015">{{cite journal|last1=Le Goues|first1=Claire|author1-link=Claire Le Goues|last2=Holtschulte|first2=Neal|last3=Smith|first3=Edward K.|last4=Brun|first4=Yuriy|last5=Devanbu|first5=Premkumar|last6=Forrest|first6=Stephanie|last7=Weimer|first7=Westley|title=The ManyBugs and IntroClass Benchmarks for Automated Repair of C Programs|journal=IEEE Transactions on Software Engineering|volume=41|issue=12|year=2015|pages=1236–1256|issn=0098-5589|doi=10.1109/TSE.2015.2454513|doi-access=free}}</ref> is a benchmark of 185 C bugs in nine open-source programs.
* Defects4J<ref name="JustJalali2014">{{cite book|last1=Just|first1=René|title=Proceedings of the 2014 International Symposium on Software Testing and Analysis – ISSTA 2014|pages=437–440|last2=Jalali|first2=Darioush|last3=Ernst|first3=Michael D.|s2cid=12796895|chapter=Defects4J: a database of existing faults to enable controlled testing studies for Java programs|year=2014|doi=10.1145/2610384.2628055|isbn=9781450326452|citeseerx=10.1.1.646.3086}}</ref> is a benchmark of 341 Java bugs from 5 open-source projects. It contains the corresponding patches, which cover a variety of patch type.
 
Line 329 ⟶ 342:
== In popular culture ==
* In video gaming, the term "[[glitch#Video game glitches|glitch]]" is sometimes used to refer to a software bug. An example is the glitch and [[List of Pokémon|unofficial Pokémon species]] [[MissingNo.]]
* In both the 1968 novel ''[[2001: A Space Odyssey (novel)|2001: A Space Odyssey]]'' and the corresponding [[2001: A Space Odyssey|film of the same name]], the spaceship's onboard computer, [[HAL 9000]], attempts to kill all its crew members. In the follow-up 1982 novel, ''[[2010: Odyssey Two]]'', and the accompanying 1984 film, ''[[2010: The Year We Make Contact|]]''2010: The Year We Make Contact'']], it is revealed that this action was caused by the computer having been programmed with two conflicting objectives: to fully disclose all its information, and to keep the true purpose of the flight secret from the crew; this conflict caused HAL to become paranoid and eventually homicidal.
* In the English version of the Nena 1983 song ''[[99 Luftballons]]'' (99 Red Balloons) as a result of "bugs in the software", a release of a group of 99 red balloons are mistaken for an enemy nuclear missile launch, requiring an equivalent launch response and resulting in catastrophe.
* In the 1999 American comedy ''[[Office Space]]'', three employees attempt (unsuccessfully) to exploit their company's preoccupation with the Y2K computer bug using a computer virus that sends rounded-off fractions of a penny to their bank account—a long-known technique described as [[salami slicing]].