{
  "id": "go/race-detector-unsynchronized-slice-append",
  "signature": "WARNING: DATA RACE\nRead at 0x... by goroutine N:\n  runtime.growslice()\nPrevious write at 0x... by goroutine M:\n  main.append()",
  "signature_zh": "WARNING: DATA RACE\n由 goroutine N 在 0x... 读取：\n  runtime.growslice()\n由 goroutine M 在 0x... 之前写入：\n  main.append()",
  "regex": "WARNING:\\ DATA\\ RACE\\\nRead\\ at\\ 0x\\.\\.\\.\\ by\\ goroutine\\ N:\\\n\\ \\ runtime\\.growslice\\(\\)\\\nPrevious\\ write\\ at\\ 0x\\.\\.\\.\\ by\\ goroutine\\ M:\\\n\\ \\ main\\.append\\(\\)",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Multiple goroutines call append() on the same slice header without synchronization, causing races on the backing array and length field.",
  "root_cause_type": "generic",
  "root_cause_zh": "多个 goroutine 在无同步的情况下对同一个 slice 头调用 append()，导致对底层数组和长度字段的竞态。",
  "versions": [
    {
      "version": "1.18",
      "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": "",
      "why_fails": "Preallocation avoids reallocation but the length field and slots are still written concurrently.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Concurrent writes to distinct indices of the same array are still data races unless synchronized.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "var mu sync.Mutex\nvar out []T\nmu.Lock()\nout = append(out, v)\nmu.Unlock()",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.93,
      "how": "results := make(chan T, n)\n// producers: results <- v\n// consumer: for v := range results { out = append(out, 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.88,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-04-18",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}