{
  "id": "go/mutex-not-unlocked",
  "signature": "fatal error: sync: unlock of unlocked mutex",
  "signature_zh": "致命错误：sync：解锁未锁定的互斥锁",
  "regex": "fatal\\ error:\\ sync:\\ unlock\\ of\\ unlocked\\ mutex",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Attempting to unlock a mutex that is not locked, often due to double unlock or unlocking in wrong goroutine.",
  "root_cause_type": "generic",
  "root_cause_zh": "尝试解锁一个未锁定的互斥锁，通常是由于重复解锁或在错误的 goroutine 中解锁。",
  "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": "Adding a flag to check if mutex is locked",
      "why_fails": "Mutex does not expose lock state; race conditions on the flag.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    },
    {
      "action": "Using recover() to ignore the panic",
      "why_fails": "Recovering does not fix the logic error; may cause data corruption.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Always use defer to unlock immediately after lock",
      "success_rate": 0.95,
      "how": "mu.Lock()\ndefer mu.Unlock()\n// critical section",
      "condition": "",
      "sources": []
    },
    {
      "action": "Ensure unlock is called exactly once per lock",
      "success_rate": 0.9,
      "how": "Use paired Lock/Unlock in same function; avoid manual unlock in error paths without defer.",
      "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.85,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-06-01",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}