{
  "id": "go/goroutine-leak-runtime-numgoroutine-grows-unbounded-ppro",
  "signature": "goroutine leak: runtime.NumGoroutine() grows unbounded; pprof shows goroutines blocked in chan send",
  "signature_zh": "goroutine 泄漏：runtime.NumGoroutine() 无限增长；pprof 显示 goroutine 阻塞在 chan send",
  "regex": "goroutine\\ leak:\\ runtime\\.NumGoroutine\\(\\)\\ grows\\ unbounded;\\ pprof\\ shows\\ goroutines\\ blocked\\ in\\ chan\\ send",
  "domain": "go",
  "category": "resource_error",
  "subcategory": null,
  "root_cause": "Producer goroutines block forever on an unbuffered channel because the consumer returned early (error/timeout) and nobody drains the channel.",
  "root_cause_type": "generic",
  "root_cause_zh": "生产者 goroutine 因消费者提前返回（错误/超时）而永久阻塞在无缓冲 channel 的发送上，且无人再消费该 channel。",
  "versions": [
    {
      "version": "1.19",
      "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"
    },
    {
      "version": "1.23",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Delays the leak; once the buffer fills under sustained load the goroutines block again.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "GC does not collect blocked goroutines; they remain referenced by the scheduler.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "go func() {\n    defer close(out)\n    for _, x := range items {\n        select {\n        case out <- x:\n        case <-ctx.Done():\n            return\n        }\n    }\n}()",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.88,
      "how": "defer func() {\n    for range out {}\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.85,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-08-27",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}