Create atest case 203
tion. Try running the offending program in a different environment. By
environment, we mean things like user account, environment variables,
registry settings, system load, and so forth. A different environment still
means on the same platform, by which we mean operating system and
hardware architecture.
Under what circumstances is this type of stabilization helpful? If a prob-
lem occurs on the submitter's account, but not on the developer's account, a
hypothesis of initialization errors, data-structure violations, or memory
problems is a good place to start. The same hypotheses are also indicated if
a program fails when running standalone but works correctly when running
under a debugger.
Finally, it's sometimes useful to try running the offending program on a
different platform. Of course, if the program relies on specific features of
the operating system or hardware, this may not be possible. Even if a com-
pletely different platform is out of the question, you may be able to use
related platforms, such as different versions of the same operating system.
For example, you might not be able to take a program developed on a ver-
sion of UNIX
and run it on Windows
but you might be able to run
it on Linux
Under what circumstances is this type of stabilization helpful? If you run
the program on a different platform and notice that discrepancies in float-
ing-point output change, a hypothesis of value corruption due to different
floating-point hardware or libraries is reasonable. If the application is
dependent on vendor-provided versions of industry-standard libraries, and
you see differences in behavior from one platform to another, a hypothesis
of problems in other people's software is warranted.
Stabilization is one of the first things we do when diagnosing a bug. If
done correctly, it can provide you with a number of qualified working
Create a test case
Almost all works on debugging recommend creating a standalone test case
from the original defective program. There are several benefits to creating
such a test case.
First, if done correctly, your test case should take significantly less time
to manifest the problem than the original program. This means that you
will be able to complete experiments much more quickly than if you run
the original program.
I Chapter 8

Get Debugging by Thinking now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.