{
  "id": "go/select-on-nil-channel-blocks",
  "signature": "fatal error: all goroutines are asleep - deadlock! (select on nil channel)",
  "signature_zh": "致命错误：所有 goroutine 都处于休眠状态 - 死锁！（在 nil 通道上 select）",
  "regex": "fatal\\ error:\\ all\\ goroutines\\ are\\ asleep\\ \\-\\ deadlock!\\ \\(select\\ on\\ nil\\ channel\\)",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "A select statement with a nil channel case blocks forever because sending/receiving on nil channel blocks indefinitely.",
  "root_cause_type": "generic",
  "root_cause_zh": "包含 nil 通道的 select 语句会永远阻塞，因为对 nil 通道的发送/接收会无限期阻塞。",
  "versions": [
    {
      "version": "1.0",
      "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": "Adding a default case to select",
      "why_fails": "Default case runs if all channels are nil, but if only some are nil, it may still block.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "Checking channel for nil before select",
      "why_fails": "If channel becomes nil dynamically, race condition may occur.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Initialize channels before using in select",
      "success_rate": 0.95,
      "how": "ch := make(chan int)\nselect {\ncase <-ch:\n    // handle\ncase <-time.After(time.Second):\n    // timeout\n}",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use a non-nil placeholder channel if channel may be nil",
      "success_rate": 0.85,
      "how": "if ch == nil { ch = make(chan int) } // but ensure it's used properly",
      "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-08-15",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}