{
  "id": "go/invalid-memory-address-or-nil-pointer-dereference-in-select",
  "signature": "invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation]",
  "signature_zh": "无效的内存地址或空指针解引用 [信号 SIGSEGV: 分段违规]",
  "regex": "invalid memory address or nil pointer dereference \\[signal SIGSEGV: segmentation violation\\]",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Dereferencing a nil pointer in a goroutine, often inside a select statement or channel operation where a pointer was not properly initialized.",
  "root_cause_type": "generic",
  "root_cause_zh": "在 goroutine 中解引用空指针，通常发生在 select 语句或通道操作中，指针未正确初始化。",
  "versions": [
    {
      "version": "go1.18",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "go1.19",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "go1.20",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "go1.21",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "SIGSEGV is a signal, not a panic; recover() cannot catch segmentation violations—the program still crashes.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Nil pointer dereference is not a race condition; the pointer is nil regardless of synchronization.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Add explicit nil checks before dereferencing: `if ptr != nil { ptr.Field = value } else { log.Fatal(\"ptr is nil\") }`",
      "success_rate": 0.95,
      "how": "Add explicit nil checks before dereferencing: `if ptr != nil { ptr.Field = value } else { log.Fatal(\"ptr is nil\") }`",
      "condition": "",
      "sources": []
    },
    {
      "action": "Initialize all pointers with make or new before use: `ptr = new(StructType)` or `ptr = &StructType{}`",
      "success_rate": 0.9,
      "how": "Initialize all pointers with make or new before use: `ptr = new(StructType)` or `ptr = &StructType{}`",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Add explicit nil checks before dereferencing: `if ptr != nil { ptr.Field = value } else { log.Fatal(\"ptr is nil\") }`",
    "Initialize all pointers with make or new before use: `ptr = new(StructType)` or `ptr = &StructType{}`"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://go.dev/doc/faq#nil_error",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.86,
  "fix_success_rate": 0.9,
  "resolvable": "true",
  "first_seen": "2023-08-05",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}