go
runtime_error
ai_generated
true
fatal error: 所有 goroutine 都处于休眠状态 - 死锁!
fatal error: all goroutines are asleep - deadlock!
ID: go/all-goroutines-asleep-deadlock
80%修复率
90%置信度
0证据数
2024-07-02首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 1.0+ | active | — | — | — |
根因分析
所有 goroutine 都阻塞在 channel 操作、互斥锁或 WaitGroup 上,没有任何可运行的 goroutine 能解除阻塞。运行时检测到完全静止后终止程序。
English
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.
解决方案
-
93% 成功率
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% 成功率
// runtime: kill -QUIT <pid> or send SIGQUIT; inspect 'goroutine N [chan send/receive]' lines
无效尝试
常见但无效的做法:
-
70% 失败
Timeout converts the deadlock into a silent timeout error, hiding the missing sender/receiver. The program still fails to make progress.
-
75% 失败
If no receiver ever reads, buffering only delays the deadlock; once the buffer fills, the sender blocks again.