{
  "id": "go/goroutine-atomic-load-store-race",
  "signature": "fatal error: concurrent atomic operations on misaligned memory",
  "signature_zh": "致命错误：对未对齐内存的并发原子操作",
  "regex": "fatal\\ error:\\ concurrent\\ atomic\\ operations\\ on\\ misaligned\\ memory",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Using atomic operations on a variable that is not properly aligned, causing a panic on some architectures (e.g., ARM).",
  "root_cause_type": "generic",
  "root_cause_zh": "对未正确对齐的变量使用原子操作，在某些架构（如 ARM）上导致恐慌。",
  "versions": [
    {
      "version": "1.20",
      "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": "Assuming atomic operations work on any variable regardless of alignment.",
      "why_fails": "Some platforms require 64-bit alignment for 64-bit atomics; misalignment causes panic.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "Using a struct with atomic fields without ensuring alignment.",
      "why_fails": "Fields may be packed in a way that causes misalignment.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Ensure atomic variables are 64-bit aligned, e.g., by using a struct with proper padding.",
      "success_rate": 0.95,
      "how": "type Aligned struct {\n    _    [0]int64 // ensure alignment\n    val  int64\n}\nvar a Aligned\natomic.StoreInt64(&a.val, 42)\nfmt.Println(atomic.LoadInt64(&a.val))",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use sync.Mutex instead of atomic for non-critical paths.",
      "success_rate": 0.9,
      "how": "var mu sync.Mutex\nvar val int64\nmu.Lock()\nval = 42\nmu.Unlock()\nmu.Lock()\nfmt.Println(val)\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.83,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2025-03-10",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}