{
  "id": "embedded/freertos-mutex-deadlock",
  "signature": "FreeRTOS: Mutex deadlock detected in task 'SensorTask' waiting for semaphore 0x2000ABCD, held by 'ControlTask' (blocked for 5000 ms)",
  "signature_zh": "FreeRTOS：任务'SensorTask'中检测到互斥锁死锁，等待信号量0x2000ABCD，由'ControlTask'持有（已阻塞5000毫秒）",
  "regex": "FreeRTOS: Mutex deadlock detected in task '[A-Za-z0-9_]+' waiting for semaphore 0x[0-9A-Fa-f]+, held by '[A-Za-z0-9_]+' \\(blocked for \\d+ ms\\)",
  "domain": "embedded",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Two or more tasks are waiting indefinitely for mutexes held by each other, typically due to incorrect locking order or missing timeout in priority inversion scenarios.",
  "root_cause_type": "generic",
  "root_cause_zh": "两个或多个任务无限期等待对方持有的互斥锁，通常由于锁定顺序不正确或在优先级反转场景中缺少超时引起。",
  "versions": [
    {
      "version": "FreeRTOS Kernel V10.5.1",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "FreeRTOS Kernel V11.0.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "STM32Cube_FW_F4_V1.27.1",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Deadlock is a synchronization issue, not a memory issue; larger stacks don't resolve lock ordering conflicts.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "This hides the symptom but the system remains hung; tasks never progress.",
      "fail_rate": 1.0,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Binary semaphores don't prevent priority inversion or deadlock; the same circular dependency persists.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Implement a consistent lock ordering: always acquire mutexes in the same order (e.g., SensorMutex before ControlMutex) across all tasks.",
      "success_rate": 0.9,
      "how": "Implement a consistent lock ordering: always acquire mutexes in the same order (e.g., SensorMutex before ControlMutex) across all tasks.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Add a timeout to semaphore takes (e.g., 100 ms) and release all held mutexes on timeout, then retry, to break deadlocks.",
      "success_rate": 0.85,
      "how": "Add a timeout to semaphore takes (e.g., 100 ms) and release all held mutexes on timeout, then retry, to break deadlocks.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use a recursive mutex if a single task may re-acquire the same mutex (e.g., via nested function calls).",
      "success_rate": 0.8,
      "how": "Use a recursive mutex if a single task may re-acquire the same mutex (e.g., via nested function calls).",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Implement a consistent lock ordering: always acquire mutexes in the same order (e.g., SensorMutex before ControlMutex) across all tasks.",
    "Add a timeout to semaphore takes (e.g., 100 ms) and release all held mutexes on timeout, then retry, to break deadlocks.",
    "Use a recursive mutex if a single task may re-acquire the same mutex (e.g., via nested function calls)."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://www.freertos.org/Documentation/02-Kernel/02-API-reference/01-Queues/01-xQueueSemaphoreTake",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.87,
  "fix_success_rate": 0.88,
  "resolvable": "true",
  "first_seen": "2024-05-20",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}