Tuesday, January 8, 2008

What is a bug?

A software bug is an error, flaw, mistake, failure, or fault in a computer program that prevents it from working as intended, or produces an incorrect result. A program that contains a large number of bugs, and/or bugs that seriously interfere with its functionality, is said to be buggy. It is said that there are bugs in all useful computer programs, but well-written programs contain relatively few bugs, Reports about bugs in a program are referred to as bug reports, also called PRs (problem reports), trouble reports, CRs (change requests), and so forth. 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. More serious bugs may cause the program to crash or freeze. Other bugs lead to security problems; for example, a common type of bug which allows a buffer overflow may allow a malicious user to execute other programs that are normally not allowed to run.

Common types of computer bugs

  • Divide by zero
  • Infinite loops
  • Arithmetic overflow or underflow
  • Exceeding array bounds

· Using an uninitialized variable

  • Accessing memory not owned (Access violation)
  • Memory leak or Handle leak
  • Stack overflow or underflow
  • Buffer overflow
  • Deadlock
  • Loss of precision in type conversion

· Syntactical errors. These are errors that your compiler should catch. Note the `should': compilers are complex pieces of software that can be buggy themselves. For example a missing ';' or a missing '}' (a syntax error) might lead to strange compiler error and warning messages. Often the place where the compiler complains is (far) after the place where the bug really is.

· Semantic bugs, such as using the wrong variable or using `&' '&&'. No compiler or other tool can find these. You'll have to do some thinking here. Testing your program step by step using a debugging tool can help you here.

No comments: