{
  "id": "go/concurrent-map-iterations",
  "signature": "fatal error: concurrent map iteration and map write",
  "signature_zh": "fatal error: 并发 map 迭代和写入",
  "regex": "fatal\\ error:\\ concurrent\\ map\\ iteration\\ and\\ map\\ write",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "A goroutine iterates a map with for range while another goroutine writes to the same map, which the runtime detects and aborts.",
  "root_cause_type": "generic",
  "root_cause_zh": "某 goroutine 使用 for range 迭代 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 without locking still races with the writer during the copy itself.",
      "fail_rate": 0.88,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Taking the snapshot races with concurrent writes and can still trigger the detector.",
      "fail_rate": 0.86,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.97,
      "how": "mu.Lock()\nfor k, v := range m { process(k, v) }\nmu.Unlock()",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.93,
      "how": "type req struct{ reply chan map[string]int }\nfor r := range reqs { r.reply <- snapshot(m) }",
      "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-06-09",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}