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.0 | active | — | — | — |
| 1.23 | active | — | — | — |
Root Cause
All goroutines are blocked waiting on channels or locks with no way to proceed, causing a program deadlock.
generic中文
所有goroutine都阻塞在通道或锁上,无法继续执行,导致程序死锁。
Workarounds
-
90% success
Use buffered channels or select with default to avoid blocking indefinitely. Ensure there is a way for goroutines to exit.
-
85% success
Implement a timeout using context.WithTimeout to break deadlocks.
Dead Ends
Common approaches that don't work:
-
90% fail
If the existing goroutines are waiting on each other, adding more will not resolve the circular wait.
-
80% fail
Sleep does not resolve the underlying synchronization issue; it only delays the deadlock detection.
-
70% fail
This breaks the program's logic and may introduce data races.