# fatal error: concurrent slice append

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

## Root Cause

Multiple goroutines appending to the same slice without synchronization, causing data race.

## Version Compatibility

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

## Workarounds

1. **Use mutex to protect slice append** (90% success)
   ```
   var mu sync.Mutex
var s []int
mu.Lock()
s = append(s, 1)
mu.Unlock()
   ```
2. **Use channel to collect results** (85% success)
   ```
   ch := make(chan int, 10)
for i := 0; i < 10; i++ {
    go func(val int) {
        ch <- val
    }(i)
}
var s []int
for i := 0; i < 10; i++ {
    s = append(s, <-ch)
}
   ```

## Dead Ends

- **Pre-allocating slice with make to avoid reallocation** — Append still modifies slice header; concurrent writes race on length. (80% fail)
- **Using copy-on-write pattern manually** — Complex and error-prone; still racy without synchronization. (70% fail)
