{
  "id": "go/channel-deadlock-all-goroutines-asleep",
  "signature": "fatal error: all goroutines are asleep - deadlock!",
  "signature_zh": "fatal error: 所有 goroutine 都处于休眠状态 - 死锁！",
  "regex": "fatal\\ error:\\ all\\ goroutines\\ are\\ asleep\\ \\-\\ deadlock!",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "The main goroutine blocked forever on a channel send/receive with no other goroutine able to unblock it. Common when receiving from an unbuffered channel with no sender, or sending with no receiver.",
  "root_cause_type": "generic",
  "root_cause_zh": "主 goroutine 在通道发送/接收上永久阻塞，且没有其他 goroutine 能够解除阻塞。常见于从无发送者的无缓冲通道接收，或向无接收者的通道发送。",
  "versions": [
    {
      "version": "1.16",
      "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": "Buffering only delays the deadlock. Once the buffer fills, the same blocking occurs; if the logic is fundamentally single-goroutine, it deadlocks regardless.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Sleeps don't create concurrency; if there is no sender goroutine at all, no amount of waiting helps.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.9,
      "how": "ch := make(chan int, 1)\nch <- 1 // non-blocking\nv := <-ch",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.85,
      "how": "select {\ncase v := <-ch:\n    use(v)\ncase <-time.After(2 * time.Second):\n    return errors.New(\"timeout\")\n}",
      "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.9,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-02-11",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}