{
  "id": "go/fatal-error-concurrent-map-read-and-map-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 a lock; the runtime detects the unsafe access pattern and aborts.",
  "root_cause_type": "generic",
  "root_cause_zh": "一个 goroutine 读取 map 的同时另一个 goroutine 写入该 map，且没有加锁；运行时检测到不安全的访问模式并终止进程。",
  "versions": [
    {
      "version": "1.17",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "1.20",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "1.23",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Copying itself iterates the map while it is written, still triggering the fatal error.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Reads still race with writes; the runtime aborts on the read/write overlap.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.96,
      "how": "var mu sync.RWMutex\nmu.RLock()\nv := m[k]\nmu.RUnlock()\nmu.Lock()\nm[k] = v2\nmu.Unlock()",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "var m sync.Map\nm.Load(k)\nm.Store(k, v)",
      "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.87,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-04-30",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}