# panic: sync: WaitGroup is reused before previous Wait has returned

- **ID:** `go/waitgroup-wait-reused`
- **Domain:** go
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

wg.Add() is called to reuse a WaitGroup while a prior wg.Wait() has not yet returned. The runtime detects the counter being reused and panics to prevent silent miscounting.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 1.20 | active | — | — |

## Workarounds

1. **** (90% success)
   ```
   Use a fresh WaitGroup per batch instead of reusing:
var wg sync.WaitGroup
for _, batch := range batches {
    wg = sync.WaitGroup{}
    // Add/Go/Wait for this batch
}
   ```
2. **** (85% success)
   ```
   Ensure all goroutines have called Done before calling Add for the next round; synchronize rounds with a barrier channel.
   ```

## Dead Ends

- **** — The reuse still happens concurrently; the panic is about ordering, not the calling goroutine. (85% fail)
- **** — Copying a WaitGroup that has been used is unsafe and may race with the in-flight Wait. (80% fail)
