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

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

## 根因

在没有匹配 Lock() 的情况下调用 mu.Unlock()，通常发生在 Lock 被跳过的路径中 defer Unlock，或 Unlock 执行了两次。

## 版本兼容性

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

## 解决方案

1. **** (94% 成功率)
   ```
   mu.Lock()
defer mu.Unlock()
// critical section
   ```
2. **** (90% 成功率)
   ```
   func (s *Store) Get(k string) V {
    s.mu.Lock()
    defer s.mu.Unlock()
    return s.m[k]
}
   ```

## 无效尝试

- **** — Swallowing the fatal error hides the logic bug and can leave the mutex in an inconsistent state. (85% 失败率)
- **** — TryLock is not a validity check for Unlock and adds races; the double-unlock still occurs. (80% 失败率)
