{
  "id": "go/goroutine-mutex-not-unlocked",
  "signature": "fatal error: sync: Unlock of unlocked mutex",
  "signature_zh": "致命错误：同步：对未锁定的互斥锁解锁",
  "regex": "fatal\\ error:\\ sync:\\ Unlock\\ of\\ unlocked\\ mutex",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Calling Unlock on a mutex that wasn't locked by the same goroutine, often due to missing Lock or double Unlock.",
  "root_cause_type": "generic",
  "root_cause_zh": "对未被同一协程锁定的互斥锁调用Unlock，通常由于缺少Lock或重复Unlock。",
  "versions": [
    {
      "version": "1.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "1.21",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Using recover() to catch panic",
      "why_fails": "Panic is fatal and cannot be recovered in Go runtime; program crashes.",
      "fail_rate": 1.0,
      "condition": "",
      "sources": []
    },
    {
      "action": "Adding more Unlock calls to match Lock",
      "why_fails": "Double unlock causes panic; correct pairing is required.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Use defer to ensure Unlock is called exactly once after Lock",
      "success_rate": 0.99,
      "how": "mu.Lock()\ndefer mu.Unlock()\n// critical section",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use sync.Mutex with proper pairing in all code paths",
      "success_rate": 0.9,
      "how": "mu.Lock()\nif condition {\n    mu.Unlock()\n    return\n}\nmu.Unlock()",
      "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-07-22",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}