What are Heisenbugs?

This will be a quick article on a funny piece of coding jargon: Heisenbug. A heisenbug is a bug that alters it's behaviour, or disappears completely when one tries to observe it. The term is a pun that comes from the Observer Effect in quantum mechanics. The classical example of this being the double-slit experiment where by very nature of shining light on a particle to observe it, one would affect it's trajectory.

More specifically, heisenbugs most often occur when using the debugger. This is because the contents of uninitialized variables may be different when using a debugger, or the debugger may change the timing of the program execution (when the program uses multiple threads). I personally experienced a heisenbug while working at Genetec. For me, the bug would flat out not appear when I used the debugger and a breakpoint in my code. But we never did find the cause of the bug, because even stranger, the bug would not appear when for my colleague when he built and ran my branch.

For further reading, check out this Wikipedia page.


Homepage