# fatal error: sync: 解锁未加锁的互斥锁

- **ID:** `go/sync-unlock-of-unlocked-mutex`
- **领域:** go
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

在没有对应 Lock() 的情况下调用 mu.Unlock()，常因双重解锁或 defer Unlock 与显式 Unlock 叠加。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 1.x | active | — | — |

## 解决方案

1. **** (95% 成功率)
   ```
   mu.Lock()
defer mu.Unlock()
// no other Unlock calls
   ```
2. **** (93% 成功率)
   ```
   func (s *Store) withLock(fn func()) {
    s.mu.Lock()
    defer s.mu.Unlock()
    fn()
}
   ```

## 无效尝试

- **** — This is a fatal error; recover cannot catch it. (100% 失败率)
- **** — The flag itself needs synchronization and often races. (75% 失败率)
