Heisenbug
A fault that changes or disappears when someone tries to observe it.
Heisenbug is a fault that changes behavior or disappears entirely when someone tries to observe it — named, as a pun on the Heisenberg uncertainty principle, for the way the act of Instrumentation perturbs the very conditions the bug depends on. Adding a print statement, attaching a debugger, or running under a profiler changes timing, memory layout, or which optimizations the compiler applies, and any of those can close the window the bug needed.
The usual causes share a theme: behavior that depends on something the source code does not fully determine. A Race Condition depends on the relative timing of concurrent operations, which logging and breakpoints both disturb. Uninitialized memory depends on whatever was already in a location before it was read, which shifts with stack layout and allocation history. Optimization-dependent behavior — a value read from a register versus reloaded from memory, a comparison the compiler proved always true — depends on flags a debug build typically turns off. This is why such a build so often fails to reproduce a bug seen in release: removing optimization removes the condition the bug needed, making it look like it was never there rather than merely hidden. The same shift happens under load: contention and Resource Starvation surface interleavings that never occur on a quiet development machine.
The fault is still Nondeterminism in the ordinary sense — the same input does not reliably produce the same output — and it produces the same symptom as a Flaky Test in a test suite: intermittent failure that resists a single Reproducible Case. The strategies that work avoid perturbing the system: logging to a lock-free buffer instead of a synchronizing output stream, execution recording that captures enough state to replay a run exactly, and deterministic replay tooling built to reproduce a specific interleaving on demand — the same idea, applied to production failures, that Record and Replay Testing applies to test suites.
See also2
Core Dump
A snapshot of a crashed program's memory saved for later inspection, how to get one, how to read one, and why it can leak secrets.
Systems & Tooling11 connections
Minimal Reproducible Example
The smallest self-contained program or set of steps that still shows a bug, and why making one is often the moment the bug gets understood.
Testing & Verification10 connections
Linked from11
- Background Tab ThrottlingWeb Platform
Browsers deliberately slow, freeze, or discard pages that are not visible, so code that assumes it keeps running in the background will be wrong.
- Core DumpSystems & Tooling
A snapshot of a crashed program's memory saved for later inspection, how to get one, how to read one, and why it can leak secrets.
- CPU SchedulerSystems & Tooling
The part of the kernel that decides which runnable thread gets each CPU core next, and for how long, trading throughput against latency.
- DeadlockComputation & Algorithms
When two or more processes each wait for something another holds, so none can ever proceed, and the four conditions that must all be true for it to happen.
- Dynamic Voltage and Frequency ScalingSystems & Tooling
Adjusting a processor's voltage and clock speed on the fly to match the work, exploiting the fact that power rises with the square of voltage.
- Flaky TestTesting & Verification
A test that passes and fails on identical input, and the most corrosive thing a suite can contain.
- Minimal Reproducible ExampleTesting & Verification
The smallest self-contained program or set of steps that still shows a bug, and why making one is often the moment the bug gets understood.
- NondeterminismAgents & Language Models
The property that identical inputs may produce different outputs, and what it costs to test around.
- Race ConditionTesting & Verification
A defect whose occurrence depends on the relative timing of concurrent operations.
- Record and ReplayTesting & Verification
Capturing real network responses once and replaying them in later test runs, which makes tests fast and deterministic but lets the recordings drift from the real service.
- Test IsolationTesting & Verification
The property that each test passes or fails on its own, regardless of which other tests run, in what order, or in parallel.