Skip to content

MoveItPy segmentation fault on teardown during object destruction (ROS 2 Jazzy, MoveIt 2.12.4) #3721

@KevinEppacherBaubot

Description

@KevinEppacherBaubot

Description

MoveItPy crashes with a segmentation fault during program exit when Python destroys the MoveItPy object, even after explicit shutdown() calls. The crash occurs consistently during the "Deleting MoveItCpp" phase and is independent of RMW implementation, blocking use in deterministic test environments.

ROS Distro

Jazzy

OS and version

Ubuntu 24.04.4 LTS (Noble), amd64, dev container environment

Source or binary build?

Binary

If binary, which release version?

ros-jazzy-moveit-py: 2.12.4-1noble.20260412.073026, ros-jazzy-moveit-core: 2.12.4-1noble.20260412.053952, ros-jazzy-moveit-ros: 2.12.4-1noble.20260412.075256

If source, which branch?

No response

Which RMW are you using?

FastRTPS

Steps to Reproduce

Reproduced with both:

rmw_fastrtps_cpp (8.4.3-1noble.20260412.034154)
rmw_cyclonedds_cpp (2.2.3-1noble.20260412.033317)

#!/usr/bin/env python3
import rclpy
from moveit.planning import MoveItPy
from ament_index_python.packages import get_package_share_directory
from moveit_configs_utils import MoveItConfigsBuilder
import os

def main():
    rclpy.init()
    
    # Load MoveIt configuration
    config_dir = os.path.join(
        get_package_share_directory("mrs15_3120_moveit_config"), 
        "config"
    )
    moveit_config = (
        MoveItConfigsBuilder("mrs15_3120", package_name="mrs15_3120_moveit_config")
        .joint_limits(file_path=os.path.join(config_dir, "joint_limits.yaml"))
        .moveit_cpp(file_path=os.path.join(config_dir, "moveit_cpp.yaml"))
        .to_moveit_configs()
    ).to_dict()
    moveit_config["use_sim_time"] = True
    
    # Initialize MoveItPy
    robot = MoveItPy(node_name="moveit_py_test", config_dict=moveit_config)
    
    # Attempt shutdown
    robot.shutdown()
    rclpy.shutdown()
    return 0

if __name__ == "__main__":
    exit(main())

moveit_cpp.yaml:

planning_scene_monitor_options:
  name: "planning_scene_monitor"
  robot_description: "robot_description"
  joint_state_topic: "/joint_states"
  attached_collision_object_topic: "/moveit_cpp/planning_scene_monitor"
  publish_planning_scene_topic: "/moveit_cpp/publish_planning_scene"
  monitored_planning_scene_topic: "/moveit_cpp/monitored_planning_scene"
  wait_for_initial_state_timeout: 10.0

planning_pipelines:
  #namespace: "moveit_cpp"  # optional, default is ~
  pipeline_names: ["ompl"]

plan_request_params:
  planning_attempts: 20
  planning_pipeline: ompl
  planner_id: "PRMkConfigDefault"
  planning_time: 20.0
  max_velocity_scaling_factor: 1.0
  max_acceleration_scaling_factor: 1.0

Expected behavior

Process should exit cleanly with exit code 0 and no crash messages.

Actual behavior

  1. MoveItPy initializes successfully and all planning components load (OMPL, adapters, controller manager).
  2. When program terminates, a segmentation fault occurs immediately after the log line:
[INFO] ... moveit.ros.moveit_cpp: Deleting MoveItCpp
[ros2run]: Segmentation fault
``
3. Exit code is none zero:
```bash
echo $?
245
  1. This occurs consistently regardless of RMW implementation (Fast DDS and Cyclone DDS both affected).
  2. Calling robot.shutdown() and rclpy.shutdown() before exit does not prevent the crash, it still occurs during Python object destruction.

This prevents using MoveItPy in deterministic test environments (e.g., pytest-based integration tests with generate_test_description. Even when motion planning/execution succeeds, the segfault at teardown causes the test runner to report failure, blocking CI/CD pipelines.

Backtrace or Console output

ros2 run baubot_motion_planning_py reproduce
WARNING:root:Cannot infer URDF from /app/install/mrs15_3120_moveit_config/share/mrs15_3120_moveit_config. -- using config/mrs15_3120.urdf
WARNING:root:Cannot infer SRDF from /app/install/mrs15_3120_moveit_config/share/mrs15_3120_moveit_config. -- using config/mrs15_3120.srdf
WARNING:root:"File /app/install/mrs15_3120_moveit_config/share/mrs15_3120_moveit_config/config/mrs15_3120.urdf doesn't exist"
WARNING:root:The robot description will be loaded from /robot_description topic
[INFO] [1778240609.970275966] [moveit_3397200009.moveit.py.cpp_initializer]: Initialize rclcpp
[INFO] [1778240609.970309280] [moveit_3397200009.moveit.py.cpp_initializer]: Initialize node parameters
[INFO] [1778240609.970320703] [moveit_3397200009.moveit.py.cpp_initializer]: Initialize node and executor
[INFO] [1778240609.974044199] [moveit_3397200009.moveit.py.cpp_initializer]: Spin separate thread
[INFO] [1778240610.063729932] [moveit_3397200009.moveit.ros.rdf_loader]: Loaded robot model in 779.837 seconds
[INFO] [1778240610.063765520] [moveit_3397200009.moveit.core.robot_model]: Loading robot model 'mrs15_3120'...
[WARN] [1778240610.236061194] [moveit_3397200009.moveit.core.robot_model]: Link track_left has visual geometry but no collision geometry. Collision geometry will be left empty. Fix your URDF file by explicitly specifying collision geometry.
[WARN] [1778240610.236104194] [moveit_3397200009.moveit.core.robot_model]: Link track_right has visual geometry but no collision geometry. Collision geometry will be left empty. Fix your URDF file by explicitly specifying collision geometry.
[WARN] [1778240610.239618834] [kdl_parser]: The root link base_link has an inertia specified in the URDF, but KDL does not support a root link with an inertia. As a workaround, you can add an extra dummy link to your URDF.
[INFO] [1778240610.239710073] [moveit_3397200009.moveit.kinematics.kdl_kinematics_plugin]: Joint weights for group 'manipulator': 1 1 1 1 1 1
[INFO] [1778240610.950237542] [moveit_3397200009.moveit.ros.planning_scene_monitor]: Publishing maintained planning scene on 'monitored_planning_scene'
[INFO] [1778240610.950333170] [moveit_3397200009.moveit.ros.moveit_cpp]: Listening to 'joint_states' for joint states
[INFO] [1778240610.950969213] [moveit_3397200009.moveit.ros.current_state_monitor]: Listening to joint states on topic 'joint_states'
[INFO] [1778240610.951164942] [moveit_3397200009.moveit.ros.planning_scene_monitor]: Listening to '/attached_collision_object' for attached collision objects
[INFO] [1778240610.951173517] [moveit_3397200009.moveit.ros.planning_scene_monitor]: Stopping existing planning scene publisher.
[INFO] [1778240610.951293856] [moveit_3397200009.moveit.ros.planning_scene_monitor]: Stopped publishing maintained planning scene.
[INFO] [1778240610.951456251] [moveit_3397200009.moveit.ros.planning_scene_monitor]: Publishing maintained planning scene on 'monitored_planning_scene'
[INFO] [1778240610.951501593] [moveit_3397200009.moveit.ros.planning_scene_monitor]: Starting planning scene monitor
[INFO] [1778240610.951642204] [moveit_3397200009.moveit.ros.planning_scene_monitor]: Listening to '/planning_scene'
[INFO] [1778240610.951648818] [moveit_3397200009.moveit.ros.planning_scene_monitor]: Starting world geometry update monitor for collision objects, attached objects, octomap updates.
[INFO] [1778240610.951853663] [moveit_3397200009.moveit.ros.planning_scene_monitor]: Listening to 'collision_object'
[INFO] [1778240610.951984057] [moveit_3397200009.moveit.ros.planning_scene_monitor]: Listening to 'planning_scene_world' for planning scene world geometry
[WARN] [1778240610.952224353] [moveit_3397200009.moveit.ros.occupancy_map_monitor]: Resolution not specified for Octomap. Assuming resolution = 0.1 instead
[ERROR] [1778240610.952232089] [moveit_3397200009.moveit.ros.occupancy_map_monitor]: No 3D sensor plugin(s) defined for octomap updates
[INFO] [1778240612.716702606] [moveit_3397200009.moveit.ros.planning_pipeline]: Successfully loaded planner 'OMPL'
[INFO] [1778240612.717868041] [moveit_py_example_node]: Try loading adapter 'default_planning_request_adapters/ResolveConstraintFrames'
[INFO] [1778240612.718485656] [moveit_py_example_node]: Loaded adapter 'default_planning_request_adapters/ResolveConstraintFrames'
[INFO] [1778240612.718498473] [moveit_py_example_node]: Try loading adapter 'default_planning_request_adapters/ValidateWorkspaceBounds'
[INFO] [1778240612.718633342] [moveit_py_example_node]: Loaded adapter 'default_planning_request_adapters/ValidateWorkspaceBounds'
[INFO] [1778240612.718639699] [moveit_py_example_node]: Try loading adapter 'default_planning_request_adapters/CheckStartStateBounds'
[INFO] [1778240612.718654617] [moveit_py_example_node]: Loaded adapter 'default_planning_request_adapters/CheckStartStateBounds'
[INFO] [1778240612.718658042] [moveit_py_example_node]: Try loading adapter 'default_planning_request_adapters/CheckStartStateCollision'
[INFO] [1778240612.718667705] [moveit_py_example_node]: Loaded adapter 'default_planning_request_adapters/CheckStartStateCollision'
[INFO] [1778240612.719754643] [moveit_py_example_node]: Try loading adapter 'default_planning_response_adapters/AddTimeOptimalParameterization'
[INFO] [1778240612.720832021] [moveit_py_example_node]: Loaded adapter 'default_planning_response_adapters/AddTimeOptimalParameterization'
[INFO] [1778240612.720843165] [moveit_py_example_node]: Try loading adapter 'default_planning_response_adapters/ValidateSolution'
[INFO] [1778240612.721769833] [moveit_py_example_node]: Loaded adapter 'default_planning_response_adapters/ValidateSolution'
[INFO] [1778240612.721782890] [moveit_py_example_node]: Try loading adapter 'default_planning_response_adapters/DisplayMotionPath'
[INFO] [1778240612.722063903] [moveit_py_example_node]: Loaded adapter 'default_planning_response_adapters/DisplayMotionPath'
[INFO] [1778240612.739073693] [moveit_3397200009.moveit.plugins.simple_controller_manager]: Added FollowJointTrajectory controller for joint_trajectory_controller
[INFO] [1778240612.739194543] [moveit_3397200009.moveit.plugins.simple_controller_manager]: Returned 1 controllers in list
[INFO] [1778240612.739214862] [moveit_3397200009.moveit.plugins.simple_controller_manager]: Returned 1 controllers in list
[INFO] [1778240612.739432791] [moveit_3397200009.moveit.ros.trajectory_execution_manager]: Trajectory execution is managing controllers
[INFO] [1778240612.740882177] [moveit_3397200009.moveit.ros.moveit_cpp]: Deleting MoveItCpp
[ros2run]: Segmentation fault

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions