Shotgun debugging
From Wikipedia, the free encyclopedia
Shotgun debugging is a process of making relatively undirected changes to software in the hope that a bug will be perturbed out of existence. This almost never works except in very simple programs, or when used as an attempt to work around programming language features that one may be using improperly; it usually introduces more bugs. These undirected, random changes can however cause more symptoms to occur, which assists in locating (and therefore fixing) problems.
A very common example of Shotgun Debugging can occur when people are working with complex multi-threaded applications. A programmer attempting to debug a race condition problem (such as a Deadlock), may find themselves writing debug text output code into the application (i.e. By using OutputDebugString in C++ or System.out.println in Java) to try and track down the problem. Since the output code itself will change the speed of one Thread in relation to another, this can cause the problem to disappear. Although apparently a solution to the problem, it is a fix by pure chance only, since anything else that changes the behaviour of the Threads may well cause it to resurface. For example a different computer may be used that has a faster processor, or a different scheduling system. Also any extra code that's added to the system may well negate any effect that the "fix" had.
It can be likened to the software equivalent of Easter egging.
This article is based in part on the Jargon File, which is in the public domain.