# panic: sync: unlock of unlocked mutex

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

## Root Cause

Calling Unlock() on a mutex that is not currently locked, often due to logic errors or double unlocking.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 1.0 | active | — | — |
| 1.22 | active | — | — |

## Workarounds

1. **** (95% success)
   ```
   Always lock before unlocking. Use defer mutex.Unlock() immediately after locking to ensure proper pairing.
   ```
2. **** (90% success)
   ```
   Use sync.RWMutex and ensure Lock/Unlock are in the same goroutine scope to avoid mismatched calls.
   ```

## Dead Ends

- **** — The panic will crash the program; ignoring it is not possible. (100% fail)
- **** — Manual tracking is error-prone and can still race; it does not solve the root cause. (80% fail)
- **** — If the lock is not acquired, defer will still call Unlock and cause the same panic. (60% fail)
