{
  "id": "go/goroutine-leak-blocked-receive",
  "signature": "goroutine leak: N goroutines blocked in chan receive (pprof shows [chan receive])",
  "signature_zh": "goroutine 泄漏: N 个 goroutine 阻塞在 chan receive（pprof 显示 [chan receive]）",
  "regex": "goroutine\\ leak:\\ N\\ goroutines\\ blocked\\ in\\ chan\\ receive\\ \\(pprof\\ shows\\ \\[chan\\ receive\\]\\)",
  "domain": "go",
  "category": "resource_error",
  "subcategory": null,
  "root_cause": "Workers were started to read from a channel that was never closed and never written to, so they block on receive forever.",
  "root_cause_type": "generic",
  "root_cause_zh": "启动了从 channel 读取的 worker，但该 channel 从未被关闭也从未写入，导致它们永久阻塞在接收上。",
  "versions": [
    {
      "version": "1.0+",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "If the loop uses for v := range ch, time.After cannot be applied; converting to select changes semantics and still leaks if done incorrectly.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Masks the leak; goroutine count still grows within the interval and can OOM under bursts.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.96,
      "how": "go func() {\n    defer close(ch)\n    for _, x := range items { ch <- x }\n}()\nfor v := range ch { process(v) }",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.94,
      "how": "for {\n    select {\n    case v, ok := <-ch:\n        if !ok { return }\n        process(v)\n    case <-ctx.Done():\n        return\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.87,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-09-03",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}