{
  "id": "go/mutex-copy-after-use",
  "signature": "panic: sync: Mutex is locked (copied value of sync.Mutex)",
  "signature_zh": "恐慌：sync: Mutex 已锁定（复制了 sync.Mutex 的值）",
  "regex": "panic:\\ sync:\\ Mutex\\ is\\ locked\\ \\(copied\\ value\\ of\\ sync\\.Mutex\\)",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "A sync.Mutex is copied after being used, which leads to undefined behavior and panic due to vet or runtime detection.",
  "root_cause_type": "generic",
  "root_cause_zh": "sync.Mutex 在使用后被复制，导致未定义行为，并因 vet 或运行时检测而恐慌。",
  "versions": [
    {
      "version": "1.19",
      "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": "Undefined behavior can corrupt data or crash later; not safe.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Copying the struct still copies the mutex; pointer receiver alone doesn't help.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "Always use pointer to the struct that holds the mutex, never copy it. Example: func (m *MyStruct) Lock()",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "Use sync.Mutex as a field and embed it in a struct that is always used via pointer.",
      "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-02-20",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}