{
  "id": "go/deadlock-multiple-channels",
  "signature": "fatal error: all goroutines are asleep - deadlock! (with 2 channels)",
  "signature_zh": "致命错误：所有 goroutine 都处于休眠状态 - 死锁！（涉及 2 个通道）",
  "regex": "fatal\\ error:\\ all\\ goroutines\\ are\\ asleep\\ \\-\\ deadlock!\\ \\(with\\ 2\\ channels\\)",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Two goroutines each waiting on a channel that the other is supposed to send to, causing a circular wait.",
  "root_cause_type": "generic",
  "root_cause_zh": "两个 goroutine 各自等待对方发送数据的通道，导致循环等待。",
  "versions": [
    {
      "version": "1.20",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Buffers only help if sends don't block; in circular wait, both block indefinitely.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "If both use timeouts, they may repeatedly timeout without progress.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "More goroutines don't resolve circular dependency; they may also block.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.9,
      "how": "ch1 := make(chan int)\nch2 := make(chan int)\ngo func() { ch1 <- 1; <-ch2 }()\ngo func() { ch2 <- 2; <-ch1 }()",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.85,
      "how": "select {\ncase v := <-ch1:\n    // handle\ncase <-time.After(time.Second):\n    // 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.81,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-04-18",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}