liveBook · Manning

Heisenbug

As explained in Learn Concurrent Programming with Go

A Heisenbug is a software bug whose behavior disappears or changes when debugging or observation alters execution timing.

A Heisenbug is a bug whose behavior disappears or changes when debugging alters execution timing. Race conditions are a classic example: pausing concurrent code can make the fault less likely to occur. section 3.3.1

Stingy and Spendy

Two Go goroutines repeatedly add to and subtract from the same bank-account variable. Although the expected result is $100, runs produce values above $4 million or below zero. Breakpoints may hide the race by changing the timing. section 3.3.1

How Learn Concurrent Programming with Go covers it

How deep it goes
Explains altered timing, shared-memory interleavings, and register updates, but stops before detailing prevention techniques.
Examples
Demonstrates unpredictable account balances through Go goroutines named Stingy and Spendy.
What you can do after
Diagnose timing-sensitive race conditions by recognizing that debugging pauses can change or conceal their behavior.
How it connects
Connects Heisenbugs with race conditions, concurrency, goroutines, shared memory, and debugging.

Also explained in

Compare how 2 books explain heisenbug →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn Concurrent Programming with Go. The section links point to the parts of the book it draws on.