# fatal error: runtime: goroutine stack exceeds 1000000000-byte limit

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

## Root Cause

Goroutines are leaked because they are blocked forever on channels or locks, causing stack memory to grow unboundedly.

## Version Compatibility

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

## Workarounds

1. **Use context with timeout to unblock goroutines** (95% success)
   ```
   ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
select {
case <-ch:
case <-ctx.Done():
    // timeout, handle cleanup
}
   ```
2. **Ensure every goroutine has a clear exit path** (98% success)
   ```
   done := make(chan struct{})
go func() {
    defer close(done)
    // work
}()
<-done
   ```

## Dead Ends

- **Increasing stack limit** — Does not fix the leak; only delays the crash. (95% fail)
- **Using time.Sleep to periodically check** — Sleep does not unblock goroutines; they remain blocked. (90% fail)
