On Software Bugs
2 On Bugs
- Bugs or Errors? "Its Not a Bug, Its a Feature"
- Definition: A bug is a deviation from functional spec.
- Implicit Specs (No matter what the input is …)
- No Crashes: Illegal ops, such as div by 0, out of range array index, …
- No Crashes: pointer values outside the address space
- No Hangs: Infinite Loop/Recursion
- No Hangs: Waiting for an Event That Won't Happen
- Classification?
- uininitialized vars; v := 0, p := nil
- off by 1
- array bounds exceeded
- ptr == nil
- memory leaks (not freed malloc-d areas)
- Knuth on TeX gives fifteen classes of errors
- See Errors in Linux
- How Many Bugs per KLOC? Anecdotal data: 0.1 to 50 bugs per KLOC
(delivered products)
3 Knuth's TeX Errors
- Donald E. Knuth, "The Errors of TeX". Published in the journal
"Software: Practice and Experience," vol 19, no. 7, pp. 607 - 685.
[Ref details below.]
- Altogether the error log contains 865 entries so far
(1989).
- Classified into 15 categories (alphabetically listed)
- Algorithmic Anomaly
- Blunder, Botch
- Cleanup for Consistency
- Datastructure Debacle
- Efficiency Enhancement
- Forgotten Function
- Generalization, Growth
- Interactive Improvement
- Language Liability
- Mismatch between Modules
- Promotion of Portability
- Quest for Quality
- Reinforced Robustness
- Surprising Scenario
- Trivial Typo
- Categories A, B, D, F, L, M, R, S, T are bugs, which definitely
needed to be removed from the code;
- Categories C, E, G, I, P, Q are enhancements, which improved but
were not obligatory.
5 Practical Debugging
- What does a "debugger" do? Lets us examine current process
state. Does not do any bug removal.
- Watch Points
- Break Points
- Stepping through code execution
- Integrated debuggers in IDEs
- Wide consensus: Highly expensive to debug using debuggers.
- Future research: Explore process state history, and with abstraction.
6 Prevention of Errors
- Why do programs have errors?
- What is the largest program you can write that has no bugs with
"normal" effort?
- Right after the first compilation?
- After one month, one year, …?
- Use assertions
- Pre-, Post-, Loop invariants, Class invariants
- Make them executable
7 Discovering Bugs by Static Analysis
- Grammars, Derivation Trees, Abstract Syntax Trees
- ./static-analysis.html
- Brittany Johnson, Yoonki Song, Emerson Murphy-Hill, and Robert
Bowdidge "Why Don't Software Developers Use Static Analysis Tools
to Find Bugs? ", http://2013.icse-conferences.org/ 35th
International Conference on Software Engineering (ICSE
2013). Reference.
8 References
- Section "Bugs Over the Years". All 3 URLS. Required Reading.
- Kim Herzig, Sascha Just, and Andreas Zeller, "Its Not a Bug, Its a
Feature: How Misclassification Impacts Bug Prediction", 35th
International Conference on Software Engineering (ICSE
2013). Reference.
- Donald E. Knuth, "The Errors of TeX". Published in the journal
"Software: Practice and Experience," vol 19, no. 7, pp. 607 - 685.
Find it on Wiley on-line archives via WSU Library proxy. Also, (i)
https://www.tug.org/texlive//devsrc/Master/texmf-dist/doc/generic/knuth/errata/errorlog.pdf,
https://www.tug.org/TUGboat/tb10-4/tb26knut.pdf, (ii)
http://tug.ctan.org/systems/knuth/dist/errata/, Knuth on TeX errors
Highly Recommended Reading.
- Donald E. Knuth, "The Errors of TeX". Published in the journal
"Software: Practice and Experience," vol 19, no. 7, pp. 607 - 685.
Find it on Wiley on-line archives via WSU Library proxy. Also, (i)
https://www.tug.org/TUGboat/tb10-4/tb26knut.pdf, (ii)
http://tug.ctan.org/systems/knuth/dist/errata/, Knuth on TeX errors
Highly Recommended Reading.
- http://www.coverity.com/library/pdf/linux_report.pdf 2004. Required
Reading.
- Norman Matloff and Peter Jay Salzman, "Art of Debugging with GDB,
DDD, and Eclipse," No Starch Press, September 2008, 280 pp. ISBN:
978-1-59327-174-9. [DDD is a GUI front end for GDB]. [Book]
Recommended Reading.
- Andreas Zeller, "Why Programs Fail: A Guide to Systematic
Debugging", Morgan Kaufmann, 424pp, 2009, ISBN: 978-0-12-374515-6.
[Book] Reference.
- https://www.udacity.com/ Online Course on Debugging by Andreas
Zeller. Free. Recommended.