# WARNING: DATA RACE
由 goroutine N 在 0x... 读取：
  runtime.growslice()
由 goroutine M 在 0x... 之前写入：
  main.append()

- **ID:** `go/race-detector-unsynchronized-slice-append`
- **领域:** go
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

多个 goroutine 在无同步的情况下对同一个 slice 头调用 append()，导致对底层数组和长度字段的竞态。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 1.18 | active | — | — |
| 1.22 | active | — | — |

## 解决方案

1. **** (95% 成功率)
   ```
   var mu sync.Mutex
var out []T
mu.Lock()
out = append(out, v)
mu.Unlock()
   ```
2. **** (93% 成功率)
   ```
   results := make(chan T, n)
// producers: results <- v
// consumer: for v := range results { out = append(out, v) }
   ```

## 无效尝试

- **** — Preallocation avoids reallocation but the length field and slots are still written concurrently. (85% 失败率)
- **** — Concurrent writes to distinct indices of the same array are still data races unless synchronized. (80% 失败率)
