# fatal error: concurrent slice read and slice write

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

## Root Cause

Multiple goroutines access the same slice without synchronization, causing data races.

## Version Compatibility

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

## Workarounds

1. **Use a mutex to synchronize all accesses** (95% success)
   ```
   var mu sync.Mutex
mu.Lock()
slice[i] = value
mu.Unlock()
   ```
2. **Use atomic operations for simple types** (90% success)
   ```
   var val atomic.Value
val.Store(mySlice)
// then load and use
   ```

## Dead Ends

- **Using a channel to pass slice elements** — If the underlying slice is still shared, races can occur on the backing array. (80% fail)
- **Copying the slice before writing** — Shallow copy shares the underlying array; deep copy needed. (75% fail)
