{
  "id": "go/goroutine-racy-slice-append",
  "signature": "fatal error: concurrent slice append",
  "signature_zh": "致命错误：并发slice追加",
  "regex": "fatal\\ error:\\ concurrent\\ slice\\ append",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Multiple goroutines appending to the same slice without synchronization, causing data race.",
  "root_cause_type": "generic",
  "root_cause_zh": "多个协程向同一个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": "Pre-allocating slice with make to avoid reallocation",
      "why_fails": "Append still modifies slice header; concurrent writes race on length.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "Using copy-on-write pattern manually",
      "why_fails": "Complex and error-prone; still racy without synchronization.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Use mutex to protect slice append",
      "success_rate": 0.9,
      "how": "var mu sync.Mutex\nvar s []int\nmu.Lock()\ns = append(s, 1)\nmu.Unlock()",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use channel to collect results",
      "success_rate": 0.85,
      "how": "ch := make(chan int, 10)\nfor i := 0; i < 10; i++ {\n    go func(val int) {\n        ch <- val\n    }(i)\n}\nvar s []int\nfor i := 0; i < 10; i++ {\n    s = append(s, <-ch)\n}",
      "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-10-05",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}