Heisenbug

/ˈhaɪ.zən.bʌɡ/ · Noun · Hacker Culture · Origin: 1985

Definitions

  1. A software bug that vanishes or changes behavior when you attempt to observe or debug it. Named after Heisenberg's uncertainty principle, because the act of investigation alters the system state.

    In plain English: A bug that disappears the moment you try to find it — like turning on the lights and watching the cockroaches scatter.

    Example: "Works in the debugger, crashes in production. Classic heisenbug."
  2. Heisenbugs are particularly common in multithreaded code, where adding logging or debugger breakpoints changes thread timing enough to prevent the race condition from manifesting. The family of quantum-physics-named bugs includes Bohrbugs (consistent, reproducible) and Schroedinbugs (exist until someone reads the code).

    Example: 'The crash happens every 1,000 requests in production but never in the debugger. Classic heisenbug — the debugger's overhead changes the timing just enough to hide the race condition.'

    Source: bug taxonomy

Origin Story

The bug that disappears when you try to observe it

A **Heisenbug** is a software bug that changes behavior (or vanishes entirely) when you attempt to study it — named after Werner Heisenberg's **uncertainty principle** in quantum mechanics, which states that observing a particle inevitably affects it.

The term was coined by **Jim Gray** at Berkeley in the early 1980s and popularized in his landmark 1985 paper *"Why Do Computers Stop and What Can Be Done About It?"* Heisenbugs are typically caused by race conditions, timing dependencies, or uninitialized memory. Adding a debugger changes the timing; adding print statements changes the memory layout; enabling logging changes the I/O pattern. Each observation perturbs the system just enough to make the bug disappear.

Gray's taxonomy also includes the **Bohrbug** (deterministic, like Bohr's atomic model — reliably reproducible) and the community later added the **Mandelbug** (so complex that its behavior appears chaotic) and the **Schrodinger's bug** (exists in a superposition of working and broken until a user reports it).

Coined by: Jim Gray

Context: UC Berkeley / Tandem Computers, early 1980s

Fun fact: Jim Gray won the Turing Award in 1998 for his work on database transactions. He disappeared at sea in 2007 while sailing alone near San Francisco. Despite an unprecedented volunteer search using satellite imagery analysis, he was never found.

Related Terms