# 致命错误：所有协程都处于睡眠状态 - 死锁！（缓冲通道已满）

- **ID:** `go/goroutine-channel-buffer-overflow`
- **领域:** go
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

向已满的缓冲通道发送数据，没有接收者就绪，导致发送者无限阻塞。

## 版本兼容性

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

## 解决方案

1. **Ensure sufficient consumer goroutines to drain channel** (90% 成功率)
   ```
   ch := make(chan int, 10)
go func() {
    for val := range ch {
        // consume
    }
}()
for i := 0; i < 20; i++ {
    ch <- i
}
   ```
2. **Use unbuffered channel with proper synchronization** (85% 成功率)
   ```
   ch := make(chan int)
go func() {
    for val := range ch {
        // consume
    }
}()
ch <- 42 // blocks until receiver ready
   ```

## 无效尝试

- **Increasing buffer size arbitrarily** — Only delays the problem; if consumers are missing, buffer will fill again. (70% 失败率)
- **Using non-blocking send with select default** — Default case drops data; may lose messages. (60% 失败率)
