{
  "id": "go/waitgroup-negative-counter",
  "signature": "panic: sync: negative WaitGroup counter",
  "signature_zh": "恐慌：同步：WaitGroup计数器为负",
  "regex": "panic:\\ sync:\\ negative\\ WaitGroup\\ counter",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Calling Done() more times than Add(), causing the WaitGroup counter to go negative.",
  "root_cause_type": "generic",
  "root_cause_zh": "调用Done()的次数多于Add()，导致WaitGroup计数器变为负数。",
  "versions": [
    {
      "version": "1.0",
      "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": "",
      "why_fails": "The panic will crash the program; ignoring is not possible.",
      "fail_rate": 1.0,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "This masks the bug and may cause Wait() to return prematurely.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "If Add is not called, Done will still decrement and may go negative.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "Ensure Add is called before starting goroutines and Done is called exactly once per goroutine.",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "Use a defer statement right after Add to guarantee Done is called.",
      "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.92,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-03-01",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}