{
  "id": "go/mutex-unlock-of-unlocked",
  "signature": "fatal error: sync: unlock of unlocked mutex",
  "signature_zh": "fatal error: sync: 解锁未加锁的互斥锁",
  "regex": "fatal\\ error:\\ sync:\\ unlock\\ of\\ unlocked\\ mutex",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "mu.Unlock() is called without a matching Lock(), often from a deferred Unlock in a path where Lock was skipped or Unlock ran twice.",
  "root_cause_type": "generic",
  "root_cause_zh": "在没有匹配 Lock() 的情况下调用 mu.Unlock()，通常发生在 Lock 被跳过的路径中 defer Unlock，或 Unlock 执行了两次。",
  "versions": [
    {
      "version": "1.14+",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Swallowing the fatal error hides the logic bug and can leave the mutex in an inconsistent state.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "TryLock is not a validity check for Unlock and adds races; the double-unlock still occurs.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.94,
      "how": "mu.Lock()\ndefer mu.Unlock()\n// critical section",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "func (s *Store) Get(k string) V {\n    s.mu.Lock()\n    defer s.mu.Unlock()\n    return s.m[k]\n}",
      "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-06-06",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}