{
  "id": "go/sync-once-reentrant",
  "signature": "fatal error: all goroutines are asleep - deadlock! (sync.Once.Do recursion)",
  "signature_zh": "fatal error: 所有 goroutine 都休眠 - 死锁! (sync.Once.Do 递归)",
  "regex": "fatal\\ error:\\ all\\ goroutines\\ are\\ asleep\\ \\-\\ deadlock!\\ \\(sync\\.Once\\.Do\\ recursion\\)",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "A sync.Once.Do function calls Do again on the same Once (directly or indirectly), causing self-deadlock because Once holds an internal mutex while running f.",
  "root_cause_type": "generic",
  "root_cause_zh": "sync.Once.Do 的函数再次（直接或间接）对同一个 Once 调用 Do，导致自死锁，因为 Once 在执行 f 时持有内部互斥锁。",
  "versions": [
    {
      "version": "1.18",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "1.20",
      "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 deadlock is internal to Once; no timeout can break the held mutex.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Reintroduces the data race Once was meant to prevent.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "var once sync.Once\nonce.Do(func() {\n    // do not reference `once` here\n    initConfig()\n})",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.88,
      "how": "var onceA, onceB sync.Once\nonceA.Do(initA)\nonceB.Do(initB)",
      "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.84,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-11-21",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}