{
  "id": "go/mutex-unlock-not-locked",
  "signature": "panic: sync: unlock of unlocked mutex",
  "signature_zh": "恐慌：同步：对未锁定的互斥锁解锁",
  "regex": "panic:\\ sync:\\ unlock\\ of\\ unlocked\\ mutex",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Calling Unlock on a sync.Mutex that is not locked by the current goroutine, often due to missing Lock or double Unlock.",
  "root_cause_type": "generic",
  "root_cause_zh": "在当前协程未锁定的 sync.Mutex 上调用 Unlock，通常由于缺少 Lock 或重复 Unlock。",
  "versions": [
    {
      "version": "1.20",
      "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"
    },
    {
      "version": "1.22",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Adding defer mu.Unlock() without ensuring Lock is called",
      "why_fails": "If Lock panics, Unlock still called on unlocked mutex.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "Using recover to catch panic and continue",
      "why_fails": "Does not fix root cause; logic may be inconsistent.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Always pair Lock with defer Unlock immediately",
      "success_rate": 0.99,
      "how": "mu.Lock(); defer mu.Unlock(); // critical section",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use sync.RWMutex with proper RLock/RUnlock pairing",
      "success_rate": 0.98,
      "how": "mu.RLock(); defer mu.RUnlock(); // read section",
      "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.9,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-05-12",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}