go
runtime_error
ai_generated
true
fatal error: all goroutines are asleep - deadlock!
ID: go/deadlock-all-goroutines-asleep
80%Fix Rate
90%Confidence
0Evidence
2024-01-20First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 1.18 | active | — | — | — |
| 1.20 | active | — | — | — |
| 1.22 | active | — | — | — |
Root Cause
The runtime detects that no goroutine can ever make progress — every goroutine is blocked on a channel send/receive, mutex, or WaitGroup with no possible unblocking.
generic中文
运行时检测到没有任何 goroutine 能继续推进——所有 goroutine 都阻塞在 channel 收发、互斥锁或 WaitGroup 上,且永远无法被唤醒。
Workarounds
-
90% success
ch := make(chan int, 1) go func(){ ch <- 1 }() v := <-ch -
87% success
select { case v := <-ch: _ = v case <-time.After(time.Second): return }
Dead Ends
Common approaches that don't work:
-
90% fail
The blocking condition is logical, not timing-based; sleeping just delays the fatal error.
-
85% fail
Deadlock is independent of parallelism; more OS threads do not create a receiver.