# fatal error: all goroutines are asleep - deadlock!

- **ID:** `go/goroutine-deadlock-all-goroutines-asleep`
- **Domain:** go
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

All goroutines are blocked waiting on channels or locks with no possibility of progress, typically due to circular dependencies or missing sends/receives.

## Version Compatibility

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

## Workarounds

1. **Ensure each channel send has a corresponding receive in another goroutine** (99% success)
   ```
   ch := make(chan int)
go func() {
    ch <- 1
}()
result := <-ch
   ```
2. **Use buffered channels to avoid blocking** (85% success)
   ```
   ch := make(chan int, 1)
ch <- 1
// no receiver needed immediately
   ```

## Dead Ends

- **Adding more goroutines to break the deadlock** — More goroutines will also block if they follow the same pattern, exacerbating the issue. (95% fail)
- **Using time.Sleep to wait for conditions** — Sleep does not resolve the fundamental blocking; it only delays the deadlock detection. (90% fail)
