{
  "id": "go/deadlock-with-multiple-channels",
  "signature": "fatal error: all goroutines are asleep - deadlock! (circular wait)",
  "signature_zh": "致命错误：所有 goroutine 都在休眠 - 死锁！（循环等待）",
  "regex": "fatal\\ error:\\ all\\ goroutines\\ are\\ asleep\\ \\-\\ deadlock!\\ \\(circular\\ wait\\)",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Multiple goroutines are waiting on each other's channels, forming a circular dependency that cannot be resolved.",
  "root_cause_type": "generic",
  "root_cause_zh": "多个 goroutine 在相互等待对方的通道，形成无法解决的循环依赖。",
  "versions": [
    {
      "version": "1.20",
      "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": "",
      "why_fails": "Buffering only delays the deadlock; it doesn't break the circular wait.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Sleeping doesn't guarantee the order; the race condition remains.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.85,
      "how": "select {\ncase v := <-ch1:\n    fmt.Println(v)\ncase <-time.After(time.Second):\n    fmt.Println(\"timeout\")\n}",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "type Coordinator struct {\n    ch chan int\n}\n\nfunc (c *Coordinator) Run() {\n    for v := range c.ch {\n        go func(v int) {\n            // process\n        }(v)\n    }\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.82,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-09-01",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}