{
  "id": "go/race-detector-warning",
  "signature": "WARNING: DATA RACE\nWrite at 0x... by goroutine N:\n  main.foo()\nPrevious read at 0x... by goroutine M:\n  main.bar()",
  "signature_zh": "WARNING: DATA RACE\n写操作地址 0x... 位于 goroutine N:\n  main.foo()\n此前的读操作地址 0x... 位于 goroutine M:\n  main.bar()",
  "regex": "WARNING:\\ DATA\\ RACE\\\nWrite\\ at\\ 0x\\.\\.\\.\\ by\\ goroutine\\ N:\\\n\\ \\ main\\.foo\\(\\)\\\nPrevious\\ read\\ at\\ 0x\\.\\.\\.\\ by\\ goroutine\\ M:\\\n\\ \\ main\\.bar\\(\\)",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Two goroutines accessed the same memory location without synchronization, at least one being a write. Detected only when built with -race.",
  "root_cause_type": "generic",
  "root_cause_zh": "两个 goroutine 在无同步的情况下访问同一内存位置，且至少有一个是写操作。仅在 -race 构建时能被检测到。",
  "versions": [
    {
      "version": "1.1+",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Does not create a happens-before relationship between the two accesses; race detector still fires.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Hides real bugs; production may corrupt data or crash non-deterministically.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.97,
      "how": "var mu sync.Mutex\nmu.Lock()\ncounter++\nmu.Unlock()\n// or\natomic.AddInt64(&counter, 1)",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.92,
      "how": "for _, item := range items {\n    item := item // capture by value\n    go func() { process(item) }()\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.9,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-12-01",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}