{
  "id": "go/concurrent-map-read-write-fatal",
  "signature": "fatal error: concurrent map read and map write",
  "signature_zh": "致命错误：并发读取和写入 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. The runtime's map race detector fires and crashes the process.",
  "root_cause_type": "generic",
  "root_cause_zh": "一个 goroutine 读取 map 的同时另一个 goroutine 写入该 map。运行时的 map 竞争检测器触发并导致进程崩溃。",
  "versions": [
    {
      "version": "1.18",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "1.21",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Reads racing writes still trigger the fatal error",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "The copy itself iterates the map while it is being written, still racing",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "Use sync.RWMutex: mu.RLock() for reads, mu.Lock() for writes; ensure reads also hold the lock",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.85,
      "how": "Pass map snapshots through channels so only one goroutine owns the map",
      "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-03-19",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}