# fatal error: semacquire: semacquire

goroutine 1 [semacquire]:
sync.runtime_Semacquire(...)

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

## 根因

某个同步原语（Mutex、WaitGroup、RWMutex）被持有或等待，导致无法推进；运行时报告 semacquire 死锁。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 1.18 | active | — | — |
| 1.22 | active | — | — |

## 解决方案

1. **** (90% 成功率)
   ```
   // Always lock A then B, never B then A.
muA.Lock(); muB.Lock(); ...; muB.Unlock(); muA.Unlock()
   ```
2. **** (80% 成功率)
   ```
   if !mu.TryLock() {
    return errors.New("lock timeout")
}
defer mu.Unlock()
   ```

## 无效尝试

- **** — Atomics cannot express compound invariants; logic still deadlocks. (85% 失败率)
- **** — Does not resolve lock ordering; can still deadlock. (90% 失败率)
