{
  "id": "go/race-detector-write-write",
  "signature": "WARNING: DATA RACE\nWrite at 0x00c000... by goroutine 7\nPrevious write at 0x00c000... by goroutine 8",
  "signature_zh": "WARNING: DATA RACE\n写操作 0x00c000... 由 goroutine 7 执行\n先前的写操作 0x00c000... 由 goroutine 8 执行",
  "regex": "WARNING:\\ DATA\\ RACE\\\nWrite\\ at\\ 0x00c000\\.\\.\\.\\ by\\ goroutine\\ 7\\\nPrevious\\ write\\ at\\ 0x00c000\\.\\.\\.\\ by\\ goroutine\\ 8",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Two goroutines access the same memory location without synchronization, with at least one write, detected by the race detector when running with -race.",
  "root_cause_type": "generic",
  "root_cause_zh": "两个 goroutine 在没有同步的情况下访问同一内存位置，且至少有一次写操作，在 -race 模式下被竞态检测器捕获。",
  "versions": [
    {
      "version": "1.18",
      "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": "The race is real; disabling detection does not fix corruption, which surfaces later as random crashes.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Sleep reduces the window but does not eliminate the race; the detector still reports it.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "var mu sync.Mutex\nmu.Lock()\ncounter++\nmu.Unlock()\n// or\natomic.AddInt64(&counter, 1)",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.92,
      "how": "results := make(chan int, len(items))\nfor _, it := range items {\n    it := it\n    go func(v int) { results <- compute(v) }(it)\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-04-02",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}