go
runtime_error
ai_generated
true
fatal error: all goroutines are asleep - deadlock!
ID: go/goroutine-deadlock-all-goroutines-asleep
80%Fix Rate
88%Confidence
0Evidence
2024-03-05First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 1.21 | active | — | — | — |
| 1.22 | active | — | — | — |
Root Cause
All goroutines are blocked waiting on channels or locks with no possibility of progress, typically due to circular dependencies or missing sends/receives.
generic中文
所有协程都在等待通道或锁,无法继续执行,通常是由于循环依赖或缺少发送/接收操作。
Workarounds
-
99% success Ensure each channel send has a corresponding receive in another goroutine
ch := make(chan int) go func() { ch <- 1 }() result := <-ch -
85% success Use buffered channels to avoid blocking
ch := make(chan int, 1) ch <- 1 // no receiver needed immediately
Dead Ends
Common approaches that don't work:
-
Adding more goroutines to break the deadlock
95% fail
More goroutines will also block if they follow the same pattern, exacerbating the issue.
-
Using time.Sleep to wait for conditions
90% fail
Sleep does not resolve the fundamental blocking; it only delays the deadlock detection.