# fatal error: all goroutines are asleep - deadlock! (sync.Mutex lock ordering)

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

## Root Cause

Two or more goroutines hold mutexes and wait for each other to release, creating a circular dependency.

## Version Compatibility

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

## Workarounds

1. **Always acquire locks in a consistent global order** (95% success)
   ```
   // Lock mu1 then mu2; goroutine1: mu1.Lock(); mu2.Lock(); goroutine2: mu1.Lock(); mu2.Lock()
   ```
2. **Use try-lock pattern with channels** (80% success)
   ```
   select { case <-mu: default: // avoid deadlock }
   ```

## Dead Ends

- **Using sync.RWMutex instead of Mutex** — Does not fix lock ordering issue. (90% fail)
- **Adding sleep to break deadlock** — Sleep does not resolve logical cycle. (95% fail)
