A Heisenbug is a type of software bug that seems to change its behaviour or even disappear when we try to investigate it. The name comes from the Heisenberg Uncertainty Principle in physics, which suggests that the act of observing something can affect the thing being observed.
In practice, a Heisenbug might show up during normal execution but vanish as soon as you run the debugger, add logging, or try to reproduce it under controlled conditions. This can happen due to timing issues, memory corruption, uninitialized variables, or race conditions.
For example, a program might crash randomly in production, but when you attach debugging tools, the additional processing changes the timing and the bug no longer appears. These bugs are some of the most frustrating to test because they are inconsistent and hard to pin down.
Testing for Heisenbugs often involves running the software under varied conditions, using stress or load tests, and monitoring behaviour in real-world environments. Since direct observation sometimes hides the issue, testers rely on indirect signals such as logs, error reports, and monitoring tools to uncover them.
In practice, a Heisenbug might show up during normal execution but vanish as soon as you run the debugger, add logging, or try to reproduce it under controlled conditions. This can happen due to timing issues, memory corruption, uninitialized variables, or race conditions.
For example, a program might crash randomly in production, but when you attach debugging tools, the additional processing changes the timing and the bug no longer appears. These bugs are some of the most frustrating to test because they are inconsistent and hard to pin down.
Testing for Heisenbugs often involves running the software under varied conditions, using stress or load tests, and monitoring behaviour in real-world environments. Since direct observation sometimes hides the issue, testers rely on indirect signals such as logs, error reports, and monitoring tools to uncover them.