{
  "id": "ros2/rclcpp-dual-mode-callback-group-deadlock",
  "signature": "rclcpp: Deadlock detected: callback waiting for another callback in same MutuallyExclusiveCallbackGroup",
  "signature_zh": "rclcpp: 检测到死锁：回调在同一个互斥回调组中等待另一个回调",
  "regex": "Deadlock detected: callback waiting for another callback in same MutuallyExclusiveCallbackGroup",
  "domain": "ros2",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "A callback in a MutuallyExclusiveCallbackGroup is blocking on a service or action call that requires another callback in the same group, causing a deadlock because the group only allows one callback at a time.",
  "root_cause_type": "generic",
  "root_cause_zh": "互斥回调组中的某个回调阻塞在需要同一组中另一个回调的服务或动作调用上，导致死锁，因为该组一次只允许一个回调执行。",
  "versions": [
    {
      "version": "ROS2 Humble (rclcpp 16.0.0)",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "ROS2 Iron (rclcpp 17.0.0)",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "ROS2 Rolling (rclcpp 18.0.0)",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Increase the callback group's thread count or use a ReentrantCallbackGroup",
      "why_fails": "Reentrant allows concurrent execution but does not solve the logical dependency; the service call still blocks.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "Add a sleep or yield in the callback",
      "why_fails": "Sleeping does not release the callback group lock; the deadlock persists.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Move the blocking service call to a separate callback group (e.g., a ReentrantCallbackGroup) so it does not block the original group: auto callback_group = this->create_callback_group(rclcpp::CallbackGroupType::Reentrant);",
      "success_rate": 0.9,
      "how": "Move the blocking service call to a separate callback group (e.g., a ReentrantCallbackGroup) so it does not block the original group: auto callback_group = this->create_callback_group(rclcpp::CallbackGroupType::Reentrant);",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use async service clients to avoid blocking the callback entirely: auto future = client->async_send_request(request);",
      "success_rate": 0.85,
      "how": "Use async service clients to avoid blocking the callback entirely: auto future = client->async_send_request(request);",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "将阻塞的服务调用移动到单独的回调组（例如ReentrantCallbackGroup），使其不会阻塞原始组：auto callback_group = this->create_callback_group(rclcpp::CallbackGroupType::Reentrant);",
    "使用异步服务客户端以避免完全阻塞回调：auto future = client->async_send_request(request);"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://docs.ros2.org/latest/api/rclcpp/classrclcpp_1_1CallbackGroup.html",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.9,
  "fix_success_rate": 0.85,
  "resolvable": "true",
  "first_seen": "2024-01-10",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}