debugging-strategy
Debugging Strategy
Purpose
Systematic, evidence-based debugging — no random changes, no shotgun fixes.
Scientific Method for Debugging
Debugging is the scientific method applied to software. Every investigation must follow observe → hypothesize → test → conclude. No exceptions.
Bug Taxonomy
Understanding the bug class helps select the right technique. Logic bugs: code does something unintended, runs without crashing. Memory bugs: leaks, use-after-free, buffer overflow, null dereference. Concurrency bugs: race conditions, deadlocks, livelocks, starvation. Performance bugs: slow code paths, resource contention, suboptimal algorithms. Configuration bugs: system works correctly but inputs, flags, or environment are wrong. Heisenbugs: behavior changes under observation (debugger, logging, different timing). Distributed bugs: network partitions, partial failures, clock skew, inconsistent state across services. Each class responds best to specific tools: Valgrind for memory, thread sanitizers for concurrency, profilers for performance, structured logging for distributed bugs. Classifying the bug before choosing tools prevents wasted effort — do not profile a logic bug, do not bisect a memory corruption bug.
Bug Severity Assessment
Not every bug deserves the same level of investment. Critical: data loss, security vulnerability, complete service outage, P0 customer impact. Fix immediately, full debugging protocol. Major: degraded functionality, partial outage, high-severity regression. Fix within sprint, follow full protocol. Minor: cosmetic issue, edge case in unused code path, low-frequency error. Log and schedule for next triage, minimal debugging effort. Classify severity before starting — urgent bugs may skip the full scientific method in favor of rapid containment, then revisit for root cause analysis.
Observe
Collect exact failure symptoms. What input reproduces the bug? What state is the system in at the moment of failure? Capture logs, stack traces, metrics, screenshots, core dumps. Reproduce the bug at least twice consecutively — a bug you cannot reproduce is a bug you cannot fix. If reproduction is intermittent, identify the frequency pattern (every N requests, only under load, only on specific hardware or OS version). Record the environment: OS, runtime version, dependency versions, configuration values, deployment topology. Environment drift is a common cause of heisenbugs.