{
  "id": "go/concurrent-map-iteration-and-write",
  "signature": "fatal error: concurrent map iteration and map write",
  "signature_zh": "致命错误: 并发遍历 map 与写 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 range while another goroutine writes to it, which the runtime flags as a fatal race.",
  "root_cause_type": "generic",
  "root_cause_zh": "一个 goroutine 用 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": "The write still races with the copy loop and can panic during the copy itself.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.93,
      "how": "Hold an RWMutex read lock for the whole iteration and use a write lock for mutations.",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.88,
      "how": "Snapshot the map under a lock into a plain slice, then iterate the slice outside the lock.",
      "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.88,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-06-03",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}