go
concurrency_error
ai_generated
true
fatal error: all goroutines are asleep - deadlock!
ID: go/channel-deadlock
88%Fix Rate
90%Confidence
50Evidence
2023-01-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 1 | active | — | — | — |
| 1 | active | — | — | — |
Root Cause
All goroutines blocked waiting on channels. No goroutine can make progress.
genericWorkarounds
-
92% success Ensure every channel send has a corresponding receive (and vice versa)
and vice versa
-
88% success Use select with default case for non-blocking channel operations
select { case msg := <-ch: handle(msg) default: // don't block } -
85% success Close channels when done sending: close(ch)
close(ch)
Sources: https://go.dev/ref/spec#Close
Dead Ends
Common approaches that don't work:
-
Use buffered channels with large buffer
65% fail
Large buffers just delay the deadlock
Error Chain
Leads to: