What is Heisenbug?

As a QA, Heisenbug has been a trouble for me. In response to a reported crash, the developer would say that he can’t reproduce the bug. The software is working fine at developers’ machines. But same bug is appearing at QAs’ machine regularly. These are real testing times for a QA. If the steps to reproduce etc are mentioned accurately, then most probably the bug is Heisenbug.

Now the question is : What is Heisenbug? The Heisenbug falls under a class of software bugs that are considered exceptionally difficult to understand and repair.

A heisenbug (named after the Heisenberg Uncertainty Principle) is a software bug that disappears or alters its characteristics when an attempt is made to study it. Heisenberg’s Uncertainty Principle states, “it is fundamentally impossible to predict the position and momentum of a particle at the same time”.

One common example is a bug that occurs in a program that was compiled with an optimizing compiler, but not in the same program when compiled without optimization (e.g., for generating a debug-mode version). Another example is a bug caused by a race condition. A heisenbug may also appear in a system that does not conform to the command-query separation design guideline, since a routine called more than once could return different values each time, generating hard-to-reproduce bugs in a race condition scenario.

One common reason for heisenbug-like behaviour is that executing a program in debug mode often cleans memory before the program starts, and forces variables onto stack locations, instead of keeping them in registers. These differences in execution can alter the effect of bugs involving out-of-bounds member access or incorrect assumptions about the initial contents of memory. Another reason is that debuggers commonly provide watches or other user interfaces that cause additional code (such as property accessors) to be executed, which can, in turn, change the state of the program. Yet another reason is a fandango on core, the effect of a pointer running out of bounds. In C++, many heisenbugs are caused by uninitialized variables.

So if something is working on developer’s machine but not at staging/QA environment/server, then look around carefully, it might be a heisenbug.

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.