{
  "id": "go/goroutine-leak-channel-buffer",
  "signature": "fatal error: all goroutines are asleep - deadlock! (goroutine leak)",
  "signature_zh": "致命错误：所有goroutine都处于休眠状态 - 死锁！（goroutine泄漏）",
  "regex": "fatal\\ error:\\ all\\ goroutines\\ are\\ asleep\\ \\-\\ deadlock!\\ \\(goroutine\\ leak\\)",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Goroutines are blocked forever because a channel send has no receiver and the channel is unbuffered.",
  "root_cause_type": "generic",
  "root_cause_zh": "由于通道发送没有接收者且通道无缓冲，goroutine永远阻塞。",
  "versions": [
    {
      "version": "1.18",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "1.19",
      "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"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Increasing buffer size arbitrarily",
      "why_fails": "Only delays the leak; doesn't match send/receive pattern.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "Using time.After to timeout",
      "why_fails": "Goroutine still exists but leaks after timeout; not a clean solution.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Ensure every send has a corresponding receive",
      "success_rate": 0.95,
      "how": "// Before: ch <- 1 (no reader)\n// After: \nresult := make(chan int)\ngo func() { result <- doWork() }()\nval := <-result",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use a context with cancellation to clean up goroutines",
      "success_rate": 0.9,
      "how": "ctx, cancel := context.WithCancel(context.Background())\ngo func() {\n    select {\n    case ch <- val:\n    case <-ctx.Done():\n        return\n    }\n}()\ncancel() // cleanup",
      "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-04-05",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}