{
  "id": "go/mutex-unlock-before-lock",
  "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 mutex that is not currently locked, often due to logic errors or double unlocking.",
  "root_cause_type": "generic",
  "root_cause_zh": "在互斥锁未锁定的情况下调用Unlock()，通常由于逻辑错误或重复解锁导致。",
  "versions": [
    {
      "version": "1.0",
      "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 panic will crash the program; ignoring it is not possible.",
      "fail_rate": 1.0,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Manual tracking is error-prone and can still race; it does not solve the root cause.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "If the lock is not acquired, defer will still call Unlock and cause the same panic.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "Always lock before unlocking. Use defer mutex.Unlock() immediately after locking to ensure proper pairing.",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "Use sync.RWMutex and ensure Lock/Unlock are in the same goroutine scope to avoid mismatched calls.",
      "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.88,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-05-02",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}