# fatal error: concurrent map iteration and map write

- **ID:** `go/fatal-error-concurrent-map-iteration-and-map-write`
- **Domain:** go
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

One goroutine ranges over a map while another goroutine writes to it, which the runtime detects and aborts.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 1.18 | active | — | — |
| 1.22 | active | — | — |

## Workarounds

1. **** (92% success)
   ```
   Hold a sync.RWMutex: mu.RLock(); for k, v := range m { ... }; mu.RUnlock(), and mu.Lock() for writes.
   ```
2. **** (90% success)
   ```
   Snapshot under lock: mu.RLock(); snapshot := make(map[K]V, len(m)); for k, v := range m { snapshot[k] = v }; mu.RUnlock(); then range over snapshot.
   ```

## Dead Ends

- **** — The copy itself races with the writer; the runtime aborts during the copy loop. (85% fail)
- **** — Maps have no index operator; this does not compile, and even an equivalent iteration still races. (90% fail)
