{
  "id": "go/goroutine-nil-pointer-deref",
  "signature": "panic: runtime error: invalid memory address or nil pointer dereference",
  "signature_zh": "panic：运行时错误：无效内存地址或空指针解引用",
  "regex": "panic:\\ runtime\\ error:\\ invalid\\ memory\\ address\\ or\\ nil\\ pointer\\ dereference",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "A spawned goroutine dereferences a nil pointer, often because it captures a variable that hasn't been initialized yet, or a struct field accessed before assignment.",
  "root_cause_type": "generic",
  "root_cause_zh": "新启动的 goroutine 解引用了空指针，常见原因是捕获了尚未初始化的变量，或在赋值前访问了结构体字段。",
  "versions": [
    {
      "version": "1.18",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "1.20",
      "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": "Treats symptom; the goroutine still operates on invalid state and may corrupt downstream logic.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Hides the bug; other goroutines still crash and root cause is masked.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.9,
      "how": "Initialize all captured pointers before launching the goroutine, or pass values explicitly as function arguments: go func(cfg *Config) { ... }(cfg)",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.88,
      "how": "Use errgroup and return errors instead of panicking; validate pointer non-nil at goroutine entry.",
      "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.85,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-09-03",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}