# panic: sync: unlock of unlocked mutex

- **ID:** `go/mutex-unlock-not-locked`
- **Domain:** go
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Calling Unlock on a sync.Mutex that is not locked by the current goroutine, often due to missing Lock or double Unlock.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 1.20 | active | — | — |
| 1.21 | active | — | — |
| 1.22 | active | — | — |

## Workarounds

1. **Always pair Lock with defer Unlock immediately** (99% success)
   ```
   mu.Lock(); defer mu.Unlock(); // critical section
   ```
2. **Use sync.RWMutex with proper RLock/RUnlock pairing** (98% success)
   ```
   mu.RLock(); defer mu.RUnlock(); // read section
   ```

## Dead Ends

- **Adding defer mu.Unlock() without ensuring Lock is called** — If Lock panics, Unlock still called on unlocked mutex. (70% fail)
- **Using recover to catch panic and continue** — Does not fix root cause; logic may be inconsistent. (50% fail)
