# 致命错误：所有 goroutine 都处于休眠状态 - 死锁！

- **ID:** `go/deadlock-all-goroutines-asleep-channel`
- **领域:** go
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

所有 goroutine 都阻塞在 channel 操作或同步原语上，运行时检测到没有任何 goroutine 能继续推进。常见于无缓冲 channel 发送无接收者，或接收无发送者。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 1.0+ | active | — | — |

## 解决方案

1. **** (90% 成功率)
   ```
   ch := make(chan int, 1)
ch <- 42 // no longer blocks
// or:
go func() { ch <- 42 }()
<-ch
   ```
2. **** (85% 成功率)
   ```
   select {
case ch <- v:
case <-time.After(time.Second):
	log.Println("send timeout")
}
   ```

## 无效尝试

- **** — Sleep does not unblock a channel operation; the deadlock persists and only adds latency. The runtime still detects all goroutines asleep. (95% 失败率)
- **** — Deadlock is a fatal runtime error, not a panic; recover() cannot intercept it and the program aborts. (99% 失败率)
