{
  "id": "embedded/freertos-mutex-deadlock-detected",
  "signature": "FreeRTOS: mutex deadlock detected on handle 0x2000ABCD, task 'SensorTask' blocked indefinitely",
  "signature_zh": "FreeRTOS：在句柄 0x2000ABCD 上检测到互斥锁死锁，任务 'SensorTask' 无限期阻塞",
  "regex": "FreeRTOS: mutex deadlock detected on handle 0x[0-9A-F]+, task '[A-Za-z]+' blocked indefinitely",
  "domain": "embedded",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Circular dependency between two tasks holding and waiting for mutexes, or a task attempts to take a mutex it already holds without recursive mutex type.",
  "root_cause_type": "generic",
  "root_cause_zh": "两个任务持有并等待互斥锁形成循环依赖，或任务尝试获取已持有的互斥锁但未使用递归互斥锁类型。",
  "versions": [
    {
      "version": "FreeRTOS 10.5.1",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "CMISIS-RTOS2 2.1.3",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "ARM GCC 11.3.1",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Increase task stack size to avoid blocking",
      "why_fails": "Deadlock is caused by mutex logic, not stack overflow; larger stack does not resolve circular wait.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "Reduce mutex timeout value to force task to give up",
      "why_fails": "Reducing timeout may cause task to abandon operation prematurely, leading to data corruption or incomplete processing.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Use recursive mutex (xSemaphoreCreateRecursiveMutex) instead of standard mutex if same task needs to take mutex multiple times. Replace all xSemaphoreTake() with xSemaphoreTakeRecursive().",
      "success_rate": 0.95,
      "how": "Use recursive mutex (xSemaphoreCreateRecursiveMutex) instead of standard mutex if same task needs to take mutex multiple times. Replace all xSemaphoreTake() with xSemaphoreTakeRecursive().",
      "condition": "",
      "sources": []
    },
    {
      "action": "Implement mutex lock ordering: ensure all tasks acquire mutexes in the same global order (e.g., always lock sensor mutex before display mutex). Add assert checks using configUSE_MUTEX_DEADLOCK_DETECTION.",
      "success_rate": 0.9,
      "how": "Implement mutex lock ordering: ensure all tasks acquire mutexes in the same global order (e.g., always lock sensor mutex before display mutex). Add assert checks using configUSE_MUTEX_DEADLOCK_DETECTION.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Use recursive mutex (xSemaphoreCreateRecursiveMutex) instead of standard mutex if same task needs to take mutex multiple times. Replace all xSemaphoreTake() with xSemaphoreTakeRecursive().",
    "Implement mutex lock ordering: ensure all tasks acquire mutexes in the same global order (e.g., always lock sensor mutex before display mutex). Add assert checks using configUSE_MUTEX_DEADLOCK_DETECTION."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://www.freertos.org/Documentation/RTOS_book.html",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.88,
  "fix_success_rate": 0.9,
  "resolvable": "true",
  "first_seen": "2025-01-10",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}