{
  "id": "go/fatal-error-all-goroutines-are-asleep-deadlock-blocked-",
  "signature": "fatal error: all goroutines are asleep - deadlock! (blocked on chan receive)",
  "signature_zh": "fatal error: 所有 goroutine 都休眠 - 死锁！（阻塞在 chan receive）",
  "regex": "fatal\\ error:\\ all\\ goroutines\\ are\\ asleep\\ \\-\\ deadlock!\\ \\(blocked\\ on\\ chan\\ receive\\)",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "main receives from a channel that no goroutine ever sends to, e.g. a producer goroutine exited early due to an error or a nil channel was used.",
  "root_cause_type": "generic",
  "root_cause_zh": "main 从某个 channel 接收，但没有任何 goroutine 会向其发送，例如生产者 goroutine 因错误提前退出，或使用了 nil channel。",
  "versions": [
    {
      "version": "1.18",
      "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"
    },
    {
      "version": "1.23",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Buffer only helps if a sender exists; with no sender, receive still blocks forever.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "An empty select blocks forever too, converting deadlock into a silent hang.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.94,
      "how": "ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)\ndefer cancel()\nselect {\ncase v := <-ch:\n    use(v)\ncase <-ctx.Done():\n    return ctx.Err()\n}",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.92,
      "how": "go func() {\n    defer close(ch)\n    for _, x := range items {\n        ch <- x\n    }\n}()\nfor v := range ch { use(v) }",
      "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-06-11",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}