{
  "id": "go/map-concurrent-read-write",
  "signature": "fatal error: concurrent map read and map write",
  "signature_zh": "fatal error: 并发读取和写入 map",
  "regex": "fatal\\ error:\\ concurrent\\ map\\ read\\ and\\ map\\ write",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "One goroutine reads a map while another writes it, without synchronization. The runtime detects the conflict and aborts.",
  "root_cause_type": "generic",
  "root_cause_zh": "一个 goroutine 读取 map 的同时另一个 goroutine 写入该 map，且无同步，运行时检测到冲突并中止。",
  "versions": [
    {
      "version": "1.0+",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Copying itself iterates the map and races with concurrent writes, triggering the same fatal error.",
      "fail_rate": 0.75,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Unlocked reads still race with locked writes; the detector fires on read/write overlap.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.94,
      "how": "mu.RLock()\nv := m[key]\nmu.RUnlock()",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.88,
      "how": "type req struct{ key string; resp chan int }\nfor r := range reqs {\n    r.resp <- m[r.key]\n}",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": null,
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.9,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-05-02",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}