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

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

## Root Cause

Unbounded goroutine creation due to missing synchronization or infinite loop, causing stack memory exhaustion.

## Version Compatibility

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

## Workarounds

1. **Use worker pool with buffered channel to limit goroutines** (95% success)
   ```
   sem := make(chan struct{}, 100); for _, task := range tasks { sem <- struct{}{}; go func(t Task) { defer func() { <-sem }(); process(t) }(task) }
   ```
2. **Add context cancellation to stop goroutines** (90% success)
   ```
   ctx, cancel := context.WithCancel(context.Background()); go func() { select { case <-ctx.Done(): return; default: work() } }(); cancel()
   ```

## Dead Ends

- **Increasing stack size via debug.SetMaxStack** — Does not fix leak; only delays exhaustion. (80% fail)
- **Using runtime.GOMAXPROCS to limit concurrency** — Limits CPU parallelism, not goroutine count. (90% fail)
