# fatal error：所有 goroutine 都休眠——死锁！（空 select{}）

- **ID:** `go/select-empty-blocks-forever`
- **领域:** go
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

空 select{} 永远阻塞且没有 case。若主 goroutine 在其上阻塞且无其他存活 goroutine，运行时会报告死锁。

## 版本兼容性

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

## 解决方案

1. **** (96% 成功率)
   ```
   sig := make(chan os.Signal, 1)
signal.Notify(sig, os.Interrupt, syscall.SIGTERM)
<-sig
   ```
2. **** (95% 成功率)
   ```
   <-ctx.Done()
   ```

## 无效尝试

- **** — Busy-spins and consumes 100% CPU; not a real fix for missing shutdown logic. (85% 失败率)
- **** — The select{} never returns, so the sleep is unreachable. (95% 失败率)
