# fatal error: concurrent map read and map write

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

## Root Cause

One goroutine read a map while another wrote to it. The runtime's map implementation detects this inconsistent access and aborts the program.

## Version Compatibility

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

## Workarounds

1. **** (93% success)
   ```
   var mu sync.RWMutex
// writer
mu.Lock(); m[k]=v; mu.Unlock()
// reader
mu.RLock(); v := m[k]; mu.RUnlock()
   ```
2. **** (85% success)
   ```
   type req struct{ key string; resp chan int }
// single owner goroutine processes reqs serially
   ```

## Dead Ends

- **** — Copying a map being concurrently written also races and may panic or produce corrupted data. (85% fail)
- **** — Timing-based synchronization is unreliable and breaks under load or different GOMAXPROCS. (87% fail)
