# 致命错误：sync：解锁未加读锁的 RWMutex

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

## 根因

在没有对应 RLock() 的情况下调用 RUnlock()，常见于用 Lock() 加锁却用 RUnlock() 解锁的情况。

## 版本兼容性

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

## 解决方案

1. **** (94% 成功率)
   ```
   mu.RLock()
defer mu.RUnlock()
// read-only section
   ```
2. **** (85% 成功率)
   ```
   type RLocked struct{ mu *sync.RWMutex }
func (r RLocked) Unlock() { r.mu.RUnlock() }
   ```

## 无效尝试

- **** — Hides the panic but leaves the RWMutex in a corrupted state, causing deadlocks later. (80% 失败率)
- **** — It removes read concurrency and may mask but not fix the mismatched lock/unlock pairs. (55% 失败率)
