# fatal error: 所有 goroutine 都处于休眠状态 - 死锁！

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

## 根因

所有 goroutine 都阻塞在 channel 操作、互斥锁或 WaitGroup 上，没有任何可运行的 goroutine 能解除阻塞。运行时检测到完全静止后终止程序。

## 版本兼容性

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

## 解决方案

1. **** (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
   ```
2. **** (88% 成功率)
   ```
   // runtime: kill -QUIT <pid> or send SIGQUIT; inspect 'goroutine N [chan send/receive]' lines
   ```

## 无效尝试

- **** — Timeout converts the deadlock into a silent timeout error, hiding the missing sender/receiver. The program still fails to make progress. (70% 失败率)
- **** — If no receiver ever reads, buffering only delays the deadlock; once the buffer fills, the sender blocks again. (75% 失败率)
