{
  "id": "go/mutex-double-lock-self-deadlock",
  "signature": "fatal error: all goroutines are asleep - deadlock! (sync.Mutex.Lock on already-held lock)",
  "signature_zh": "致命错误：所有 goroutine 都已休眠 - 死锁！（对已持有的 sync.Mutex.Lock 再次加锁）",
  "regex": "fatal\\ error:\\ all\\ goroutines\\ are\\ asleep\\ \\-\\ deadlock!\\ \\(sync\\.Mutex\\.Lock\\ on\\ already\\-held\\ lock\\)",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "The same goroutine calls Lock() twice on a non-reentrant sync.Mutex, or a locked method calls another method that locks the same mutex.",
  "root_cause_type": "generic",
  "root_cause_zh": "同一个 goroutine 对不可重入的 sync.Mutex 调用两次 Lock()，或已加锁的方法调用另一个锁定同一互斥锁的方法。",
  "versions": [
    {
      "version": "1.18",
      "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 goroutine itself holds the lock; retry never succeeds",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "RLock while holding RLock is allowed but Lock after RLock still deadlocks",
      "fail_rate": 0.75,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "Split into exported methods that lock and unexported helpers that assume the lock is held; never call Lock inside a locked section",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.85,
      "how": "Use defer mu.Unlock() consistently and audit call chains for re-entrancy",
      "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.87,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-04-17",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}