{
  "id": "go/goroutine-map-concurrent-write",
  "signature": "fatal error: concurrent map writes",
  "signature_zh": "致命错误：并发map写操作",
  "regex": "fatal\\ error:\\ concurrent\\ map\\ writes",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Multiple goroutines write to a Go map without synchronization, causing a runtime crash.",
  "root_cause_type": "generic",
  "root_cause_zh": "多个协程在没有同步的情况下写入Go map，导致运行时崩溃。",
  "versions": [
    {
      "version": "1.21",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "1.22",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Using a mutex only for writes but not reads",
      "why_fails": "Concurrent reads during writes can also cause race conditions.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "Using a sync.Map incorrectly",
      "why_fails": "sync.Map has specific use cases; misuse can still cause races.",
      "fail_rate": 0.65,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Use sync.Mutex to protect all map access",
      "success_rate": 0.98,
      "how": "var mu sync.Mutex\nm := make(map[string]int)\n// write\nmu.Lock()\nm[\"key\"] = 1\nmu.Unlock()\n// read\nmu.Lock()\nval := m[\"key\"]\nmu.Unlock()",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use sync.Map for concurrent-safe map operations",
      "success_rate": 0.9,
      "how": "var m sync.Map\nm.Store(\"key\", 1)\nval, ok := m.Load(\"key\")",
      "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.89,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-11-01",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}