{
  "id": "go/goroutine-deadlock-all-goroutines-asleep",
  "signature": "fatal error: all goroutines are asleep - deadlock!",
  "signature_zh": "致命错误：所有协程都处于休眠状态 - 死锁！",
  "regex": "fatal\\ error:\\ all\\ goroutines\\ are\\ asleep\\ \\-\\ deadlock!",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "All goroutines are blocked waiting on channels or locks with no possibility of progress, typically due to circular dependencies or missing sends/receives.",
  "root_cause_type": "generic",
  "root_cause_zh": "所有协程都在等待通道或锁，无法继续执行，通常是由于循环依赖或缺少发送/接收操作。",
  "versions": [
    {
      "version": "1.21",
      "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": "Adding more goroutines to break the deadlock",
      "why_fails": "More goroutines will also block if they follow the same pattern, exacerbating the issue.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "Using time.Sleep to wait for conditions",
      "why_fails": "Sleep does not resolve the fundamental blocking; it only delays the deadlock detection.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Ensure each channel send has a corresponding receive in another goroutine",
      "success_rate": 0.99,
      "how": "ch := make(chan int)\ngo func() {\n    ch <- 1\n}()\nresult := <-ch",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use buffered channels to avoid blocking",
      "success_rate": 0.85,
      "how": "ch := make(chan int, 1)\nch <- 1\n// no receiver needed immediately",
      "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.88,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-03-05",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}