{
  "id": "go/proto-nil-pointer-deref-unmarshal",
  "signature": "panic: runtime error: invalid memory address or nil pointer dereference in proto.Unmarshal",
  "signature_zh": "panic: 运行时错误：proto.Unmarshal 中无效的内存地址或 nil 指针解引用",
  "regex": "panic:\\ runtime\\ error:\\ invalid\\ memory\\ address\\ or\\ nil\\ pointer\\ dereference\\ in\\ proto\\.Unmarshal",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "proto.Unmarshal was called with a nil message pointer, or a generated message's internal fields were not initialized (e.g., using a zero-value struct literal instead of a constructor).",
  "root_cause_type": "generic",
  "root_cause_zh": "调用 proto.Unmarshal 时传入了 nil 消息指针，或生成消息的内部字段未初始化（例如使用零值结构体字面量而非构造函数）。",
  "versions": [
    {
      "version": "google.golang.org/protobuf v1.26+",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Swallowing the panic leaves the message nil; subsequent field access panics again and corrupts control flow.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "proto.Unmarshal requires a proto.Message (pointer receiver); passing a value fails to compile or operates on a copy.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "msg := &pb.User{}\nif err := proto.Unmarshal(data, msg); err != nil { return err }",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "msg := pb.NewUser() // or &pb.User{} then reset\nif err := proto.Unmarshal(data, msg); err != nil { return err }",
      "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-05-30",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}