# fatal error: all goroutines are asleep - deadlock!
goroutine 1 [sync.Mutex.Lock]:

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

## Root Cause

A goroutine locks a sync.Mutex twice without unlocking in between, or two goroutines acquire two mutexes in opposite order. The runtime detects a full stop.

## Version Compatibility

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

## Workarounds

1. **** (96% success)
   ```
   func (s *Service) Do() {
    s.mu.Lock()
    defer s.mu.Unlock()
    // ...
}
   ```
2. **** (93% success)
   ```
   // Always lock A before B
func transfer(a, b *Account) {
    if a.id < b.id { a.mu.Lock(); b.mu.Lock() } else { b.mu.Lock(); a.mu.Lock() }
    defer a.mu.Unlock(); defer b.mu.Unlock()
}
   ```

## Dead Ends

- **** — sync.Mutex has no timeout API; you must restructure the code or use a channel-based lock. (90% fail)
- **** — All runnable goroutines are blocked on the mutex; more Ps do not help. (95% fail)
