Practice question · Multiple choice
A bug appears only in production, never locally, and disappears when logging is added. What class of bug does that pattern suggest?
Hints
- Ask what adding a log line changes about how the program runs.
- The behaviour depends on something outside the code being tested. Name the candidates.
Show the answer
D. One depending on timing or environment, which logging perturbs
Why
Logging perturbs timing and memory layout, so a bug that vanishes when observed is almost always a race, an uninitialised read, or an environment difference. They are called heisenbugs for that reason, and the useful response is to look for shared mutable state and configuration drift rather than to keep adding print statements.
Practise Debugging Logic and State
The app has 6 more questions on this lesson, and keeps your place in the course. Computer Science I is free to start.
More questions on Debugging Logic and State
- Select every practice that the lesson recommends for debugging.
- Order the steps of the disciplined debugging routine.
- Systematic debugging narrows down where the state first becomes wrong, rather than reading the code looking…
- Sort each debugging action by whether it reasons from evidence or merely guesses.