{
  "id": "go/sync-once-deadlock-recursive",
  "signature": "fatal error: all goroutines are asleep - deadlock! (sync.Once.Do calling itself)",
  "signature_zh": "致命错误：所有 goroutine 都已休眠 - 死锁！（sync.Once.Do 递归调用自身）",
  "regex": "fatal\\ error:\\ all\\ goroutines\\ are\\ asleep\\ \\-\\ deadlock!\\ \\(sync\\.Once\\.Do\\ calling\\ itself\\)",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "A sync.Once.Do function calls the same Once.Do again (directly or indirectly), blocking on its own mutex forever.",
  "root_cause_type": "generic",
  "root_cause_zh": "sync.Once.Do 的函数再次（直接或间接）调用同一个 Once.Do，永久阻塞在自己的互斥锁上。",
  "versions": [
    {
      "version": "1.21",
      "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": "Once holds an internal mutex with no timeout support; deadlock persists",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Loses thread-safety; introduces data races",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "Ensure the function passed to Do never calls the same Once; extract shared init into a separate helper",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.88,
      "how": "Use sync.OnceFunc/OnceValue (Go 1.21+) and keep init logic non-reentrant",
      "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-06-30",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}