# fatal error: all goroutines are asleep - deadlock! (WaitGroup copied)

- **ID:** `go/waitgroup-passed-by-value`
- **Domain:** go
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

A sync.WaitGroup is passed by value to a function, so Add/Done operate on a copy and Wait() on the original never unblocks.

## Version Compatibility

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

## Workarounds

1. **** (95% success)
   ```
   func worker(wg *sync.WaitGroup) {
    defer wg.Done()
    // ...
}
   ```
2. **** (92% success)
   ```
   type Pool struct { wg sync.WaitGroup }
func (p *Pool) Run() { p.wg.Add(1); go func(){ defer p.wg.Done() }() }
   ```

## Dead Ends

- **** — The copy bug remains; the timeout just papers over the deadlock without fixing counter propagation. (80% fail)
- **** — The counters are in different copies; adding to the original still does not match the copy's Done calls. (85% fail)
