{
  "id": "go/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": "sync.Mutex.Unlock() is called on a mutex that is not currently locked by this goroutine, due to double-unlock, unlock without lock, or copying a mutex value.",
  "root_cause_type": "generic",
  "root_cause_zh": "对当前未被本 goroutine 锁定的互斥锁调用了 Unlock()，原因是重复解锁、未加锁就解锁，或复制了互斥锁值。",
  "versions": [
    {
      "version": "1.16",
      "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 recoverable panic; the process aborts regardless.",
      "fail_rate": 0.98,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "This breaks the critical section semantics and can deadlock if the same goroutine already holds the lock.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.96,
      "how": "mu.Lock()\ndefer mu.Unlock()\n// critical section",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.94,
      "how": "type Counter struct {\n    mu sync.Mutex\n    n  int\n}\nfunc inc(c *Counter) { c.mu.Lock(); defer c.mu.Unlock(); c.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.9,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-03-28",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}