{
  "id": "go/fatal-error-sync-unlock-of-unlocked-mutex",
  "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 when the mutex is not held, usually because a defer unlock runs after an early return or a double unlock.",
  "root_cause_type": "generic",
  "root_cause_zh": "在互斥锁未被持有的情况下调用 mu.Unlock()，通常因为提前返回后 defer unlock 仍执行，或重复解锁。",
  "versions": [
    {
      "version": "1.18",
      "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": "",
      "why_fails": "This is a fatal runtime error, not a panic; recover cannot catch it and the process exits.",
      "fail_rate": 0.98,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "The flag itself needs synchronization and is often set incorrectly, reintroducing the bug under concurrency.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "Use defer mu.Unlock() immediately after mu.Lock() in the same function so they always pair.",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "Audit all code paths: ensure no early return between Lock and Unlock without defer, and never unlock in a different function than the one that locked.",
      "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.89,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-07-02",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}