{
  "id": "go/data-race-detector",
  "signature": "WARNING: DATA RACE\nRead at 0x00c0000b4010 by goroutine 7:",
  "signature_zh": "警告：数据竞争\nGoroutine 7 在 0x00c0000b4010 处读取：",
  "regex": "WARNING:\\ DATA\\ RACE\\\nRead\\ at\\ 0x00c0000b4010\\ by\\ goroutine\\ 7:",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "The race detector (go test -race / go run -race) found unsynchronized concurrent access to the same memory location. Usually a shared struct field or slice index accessed without a mutex or atomic.",
  "root_cause_type": "generic",
  "root_cause_zh": "竞争检测器（go test -race / go run -race）发现对同一内存位置的无同步并发访问。通常是共享结构体字段或切片索引在无 mutex/atomic 保护下访问。",
  "versions": [
    {
      "version": "1.19",
      "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"
    },
    {
      "version": "1.22",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Hides the bug; production crashes or corrupts state under real concurrency.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Does not establish happens-before; race remains and detector still fires.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "var hits atomic.Int64\nhits.Add(1)\nn := hits.Load()",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.97,
      "how": "type Counter struct {\n    mu sync.Mutex\n    n  int\n}\nfunc (c *Counter) Inc() { c.mu.Lock(); c.n++; c.mu.Unlock() }",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.92,
      "how": "results := make(chan Result)\ngo func() { results <- compute() }()\nr := <-results // ownership transferred",
      "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-02-02",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}