go
runtime_error
ai_generated
true
致命错误:所有 goroutine 都处于休眠状态 - 死锁!
fatal error: all goroutines are asleep - deadlock!
ID: go/fatal-error-all-goroutines-asleep-deadlock
80%修复率
90%置信度
0证据数
2024-01-15首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 1.0+ | active | — | — | — |
根因分析
所有 goroutine 都阻塞在 channel 或锁上,无法继续推进,Go 运行时死锁检测器触发。
English
All goroutines are blocked waiting on channels/locks with no possibility of progress; the Go runtime deadlock detector fires.
解决方案
-
95% 成功率
ch := make(chan int, 1) ch <- 1 // no receiver needed for buffered channel
-
90% 成功率
select { case v := <-ch: _ = v case <-time.After(time.Second): return errors.New("timeout") }
无效尝试
常见但无效的做法:
-
90% 失败
Sleep does not unblock the sender; the deadlock detector still fires once all goroutines park.
-
95% 失败
fatal error from the runtime is not recoverable via recover(); it calls exit directly.