go
runtime_error
ai_generated
true
fatal error: all goroutines are asleep - deadlock!
ID: go/all-goroutines-asleep-deadlock
80%Fix Rate
90%Confidence
0Evidence
2024-07-02First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 1.0+ | active | — | — | — |
Root Cause
Every goroutine is blocked on a channel operation, mutex, or WaitGroup with no runnable goroutine to unblock them. The runtime detects total quiescence and aborts.
generic中文
所有 goroutine 都阻塞在 channel 操作、互斥锁或 WaitGroup 上,没有任何可运行的 goroutine 能解除阻塞。运行时检测到完全静止后终止程序。
Workarounds
-
93% success
ch := make(chan int) done := make(chan struct{}) go func() { defer close(done); for v := range ch { _ = v } }() for i := 0; i < 10; i++ { ch <- i } close(ch) <-done -
88% success
// runtime: kill -QUIT <pid> or send SIGQUIT; inspect 'goroutine N [chan send/receive]' lines
Dead Ends
Common approaches that don't work:
-
70% fail
Timeout converts the deadlock into a silent timeout error, hiding the missing sender/receiver. The program still fails to make progress.
-
75% fail
If no receiver ever reads, buffering only delays the deadlock; once the buffer fills, the sender blocks again.