{
  "id": "go/racy-slice-access",
  "signature": "fatal error: concurrent slice read and slice write",
  "signature_zh": "致命错误：并发 slice 读取和 slice 写入",
  "regex": "fatal\\ error:\\ concurrent\\ slice\\ read\\ and\\ slice\\ write",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Multiple goroutines access the same slice without synchronization, causing data races.",
  "root_cause_type": "generic",
  "root_cause_zh": "多个 goroutine 在没有同步的情况下访问同一个 slice，导致数据竞态。",
  "versions": [
    {
      "version": "1.0",
      "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": "Using a channel to pass slice elements",
      "why_fails": "If the underlying slice is still shared, races can occur on the backing array.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "Copying the slice before writing",
      "why_fails": "Shallow copy shares the underlying array; deep copy needed.",
      "fail_rate": 0.75,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Use a mutex to synchronize all accesses",
      "success_rate": 0.95,
      "how": "var mu sync.Mutex\nmu.Lock()\nslice[i] = value\nmu.Unlock()",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use atomic operations for simple types",
      "success_rate": 0.9,
      "how": "var val atomic.Value\nval.Store(mySlice)\n// then load and use",
      "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.85,
  "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": []
}