{
  "id": "go/goroutine-nil-pointer",
  "signature": "panic: runtime error: invalid memory address or nil pointer dereference (in goroutine)",
  "signature_zh": "panic: 运行时错误：无效内存地址或空指针解引用（发生在 goroutine 中）",
  "regex": "panic:\\ runtime\\ error:\\ invalid\\ memory\\ address\\ or\\ nil\\ pointer\\ dereference\\ \\(in\\ goroutine\\)",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "A nil pointer is dereferenced inside a spawned goroutine. Because the panic happens in a child goroutine, it crashes the whole program and cannot be recovered from the parent.",
  "root_cause_type": "generic",
  "root_cause_zh": "在派生的 goroutine 中解引用了空指针。由于 panic 发生在子 goroutine 中，会导致整个程序崩溃，父 goroutine 无法 recover。",
  "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": "recover only works in the panicking goroutine's own deferred function; the parent cannot catch it.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Race-dependent nil dereference only triggers under specific interleavings; production crashes intermittently.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.93,
      "how": "go func() {\n    defer func() {\n        if r := recover(); r != nil {\n            log.Printf(\"goroutine panic: %v\", r)\n        }\n    }()\n    doWork()\n}()",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "if cfg == nil { return errors.New(\"nil cfg\") }\ngo func(c Config) { use(c) }(*cfg)",
      "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": "2024-07-02",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}