{
  "id": "go/goroutine-atomic-load-store-mismatch",
  "signature": "WARNING: DATA RACE: Write by goroutine X, Read by goroutine Y (atomic variable)",
  "signature_zh": "警告：数据竞争：协程X写入，协程Y读取（原子变量）",
  "regex": "WARNING:\\ DATA\\ RACE:\\ Write\\ by\\ goroutine\\ X,\\ Read\\ by\\ goroutine\\ Y\\ \\(atomic\\ variable\\)",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Using atomic.Load/Store on a variable that is also accessed non-atomically, causing race.",
  "root_cause_type": "generic",
  "root_cause_zh": "对同时被非原子访问的变量使用atomic.Load/Store，导致竞争。",
  "versions": [
    {
      "version": "1.4",
      "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"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Using volatile keyword (not available in Go)",
      "why_fails": "Go doesn't have volatile; atomic operations are required.",
      "fail_rate": 1.0,
      "condition": "",
      "sources": []
    },
    {
      "action": "Adding memory barrier manually",
      "why_fails": "Go's memory model is complex; manual barriers are error-prone.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Use atomic operations consistently for all accesses",
      "success_rate": 0.95,
      "how": "var val atomic.Value\nval.Store(42)\nv := val.Load().(int)",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use sync.Mutex to protect all accesses",
      "success_rate": 0.9,
      "how": "var mu sync.Mutex\nvar x int\nmu.Lock()\nx = 42\nmu.Unlock()\nmu.Lock()\nv := x\nmu.Unlock()",
      "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.86,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2025-08-05",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}