{
  "id": "go/waitgroup-passed-by-value",
  "signature": "fatal error: all goroutines are asleep - deadlock! (WaitGroup copied)",
  "signature_zh": "fatal error: 所有 goroutine 都处于休眠状态 - 死锁！（WaitGroup 被复制）",
  "regex": "fatal\\ error:\\ all\\ goroutines\\ are\\ asleep\\ \\-\\ deadlock!\\ \\(WaitGroup\\ copied\\)",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "A sync.WaitGroup is passed by value to a function, so Add/Done operate on a copy and Wait() on the original never unblocks.",
  "root_cause_type": "generic",
  "root_cause_zh": "sync.WaitGroup 按值传递给函数，导致 Add/Done 作用于副本，原对象的 Wait() 永远无法解除阻塞。",
  "versions": [
    {
      "version": "1.14+",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "The copy bug remains; the timeout just papers over the deadlock without fixing counter propagation.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "The counters are in different copies; adding to the original still does not match the copy's Done calls.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "func worker(wg *sync.WaitGroup) {\n    defer wg.Done()\n    // ...\n}",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.92,
      "how": "type Pool struct { wg sync.WaitGroup }\nfunc (p *Pool) Run() { p.wg.Add(1); go func(){ defer p.wg.Done() }() }",
      "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-08-02",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}