Software bug

Also known as: bug

On this page 7

A software bug is a defect in a program’s source code, configuration or design that causes it to produce an incorrect result, behave unexpectedly, crash or become insecure. Among software fundamentals it is the everyday name for what engineers more precisely call a fault: a flaw that exists in the software and may lead to a visible failure when particular inputs or conditions occur.

Bugs are an unavoidable property of complex software rather than a sign of carelessness alone. Any non-trivial program contains paths that were never tested, assumptions that later stop holding and interactions with libraries, hardware and operating systems that change over time. The practical goal is therefore not zero bugs but finding them early, limiting their impact and fixing them reliably through patches and new software versions.

How a software bug turns into a failure

Software engineering distinguishes three linked concepts. A human error (a mistaken assumption or a typo) introduces a fault into code or configuration. When the faulty code is executed under the right conditions, it creates an incorrect internal state, and when that state reaches the user or another system, it becomes a failure. A bug can therefore sit unnoticed for years until a rare input triggers it.

This chain explains why a bug report describes symptoms, while the fix addresses the root cause. A crash in one module is often the result of corrupted data produced elsewhere, so careful diagnosis traces the failure backward through logs, stack traces and reproduced test cases.

TermMeaningExample
Error (mistake)Human action that introduces a defectDeveloper assumes a list is never empty
Fault (defect, bug)Flaw present in code or configurationMissing check before reading the first element
InfectionIncorrect program state at run timeVariable holds an undefined value
FailureObservable deviation from expected behaviorApplication crashes when the list is empty
Terms used to describe a defect

Common types of software bugs

Bugs are usually classified by the kind of mistake behind them, because each type has typical detection methods. The table below lists the categories that appear most often in application software and system software.

Bug typeTypical causeUsual detection method
Logic errorWrong condition, formula or branchUnit tests and code review
Off-by-one errorLoop or index boundary miscountedBoundary value testing
Null or undefined referenceMissing value not checkedStatic analysis and type systems
Race conditionUnsynchronized access by concurrent threadsStress tests and thread sanitizers
Memory leak or corruptionAllocated memory not released or overwrittenMemory profilers and sanitizers
Integration bugMismatched assumptions between componentsIntegration and end-to-end tests
Configuration bugWrong setting in a configuration fileEnvironment validation and staged deployment
Bug categories and how they are usually found

Some categories deserve special attention. Heisenbugs change behavior or disappear when a debugger or logging is attached, typically because timing changes. Regressions are bugs in features that worked before and were broken by a later change, which is why teams keep automated regression test suites.

Severity, priority and the bug lifecycle

Teams rate each reported bug on two separate axes. Severity describes how much damage the bug causes, while priority describes how soon it should be fixed. A cosmetic typo on a login page can have low severity but high priority, while a crash in a rarely used export function can be severe yet scheduled later.

SeverityEffect on usersUsual response
CriticalData loss, security breach or full outageImmediate hotfix or emergency patch
MajorKey feature broken, no reasonable workaroundFix in the next release or a patch
MinorFeature impaired but a workaround existsScheduled into regular development
TrivialCosmetic issue or wording problemFixed when convenient
Typical severity levels

Most issue trackers move a bug through a lifecycle: new, confirmed, assigned, fixed, verified and closed, with possible states such as duplicate, cannot reproduce or will not fix. A good bug report contains steps to reproduce, expected and actual behavior, the software version and the environment, because a reproducible bug is usually half solved.

Software bug, security vulnerability and feature request

A software bug is not the same as every complaint about a program. A security vulnerability is a bug that an attacker can exploit, so it follows a separate process with coordinated disclosure and identifiers such as CVE numbers. A feature request asks for behavior that was never specified, so the program is not defective. Distinguishing the three keeps backlogs honest and security work properly prioritized.

Issue typeCore questionTypical outcome
Software bugDoes the program violate its specification?Code fix delivered as a patch
Security vulnerabilityCan the defect be exploited?Security update and advisory
Feature requestShould the program do something new?Planned in a future software version
Performance issueIs a correct result too slow or costly?Optimization work
How related issue types differ

Preventing and fixing bugs in practice

The cost of a bug grows the later it is found, because a defect discovered in production affects users, data and support staff, while the same defect caught in review costs minutes. Effective teams therefore combine several layers of defense rather than relying on testing at the end.

  • Static typing and static analysis catch whole classes of errors before the program runs.
  • Code review finds logic errors and unclear assumptions that tests rarely reveal.
  • Automated tests at unit, integration and end-to-end level guard against regressions.
  • Staged rollout and monitoring limit how many users a new bug can reach.
  • Root cause analysis after serious incidents fixes the process, not only the line of code.

A frequent mistake is fixing the symptom instead of the cause, for example catching an exception and ignoring it. Another is shipping a fix without a test that reproduces the original bug, which leaves the door open for the same defect to return in a later version.

Stripped to the essentials

A software bug is a mistake hidden inside a program. It is similar to a wrong step in a recipe. Most of the time the dish turns out fine. Then one day you use a different ingredient, and the mistake ruins the meal.

Programs are written by people and contain millions of instructions, so some mistakes always slip through. Good teams cannot promise perfection. They promise to find problems quickly and fix them safely.

Where it is applied

A small online store notices that some customers in one region receive invoices with totals that are a few cents wrong. Support collects three examples and files a bug report with the order numbers, the expected and actual totals and the software version of the billing service.

A developer reproduces the problem and finds the root cause: prices were stored as floating-point numbers, and rounding differed when a regional tax rate with three decimal places was applied. The team fixes the defect by switching to integer cents for all money values, adds a regression test with the exact failing orders and releases a patch. The billing errors stop, and the new test ensures that the same rounding bug cannot quietly return.