{
  "id": "go/data-race-detector-warning",
  "signature": "WARNING: DATA RACE\nWrite at 0x00c0000b4010 by goroutine 7:",
  "signature_zh": "WARNING: DATA RACE\nGoroutine 7 在 0x00c0000b4010 处写入：",
  "regex": "WARNING:\\ DATA\\ RACE\\\nWrite\\ at\\ 0x00c0000b4010\\ by\\ goroutine\\ 7:",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Two goroutines access the same memory location concurrently, at least one is a write, and no synchronization orders them. Detected only when built with -race; the program otherwise has undefined behavior.",
  "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": "Hiding the report does not fix the race; the bug persists and manifests as corrupted data or crashes in production.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Sleep reduces the probability but does not establish a happens-before relationship; the race and its undefined behavior remain.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "Protect the shared variable with a mutex:\n\nvar mu sync.Mutex\nmu.Lock()\ncounter++\nmu.Unlock()",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.92,
      "how": "Use atomic operations for simple counters:\n\nvar counter int64\natomic.AddInt64(&counter, 1)\n_ = atomic.LoadInt64(&counter)",
      "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-07-15",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}