moveit_task_constructor icon indicating copy to clipboard operation
moveit_task_constructor copied to clipboard

Segfault when creating multiple tasks

Open JSchaaf2 opened this issue 2 years ago • 6 comments

I was creating a minimal example for another issue and finally stumbled on a something that looks a lot like another issue I had but never found a minimal example for.

modefied doTask() from pick and place tutorial
void MTCTaskNode::doTask() {
    task_ = createTask();
    task2 = createTask();

    try
    {
        task_.init();
    }
    catch (mtc::InitStageException& e)
    {
        RCLCPP_ERROR_STREAM(LOGGER, e);
        return;
    }
    if (!task_.plan(5))
    {
        RCLCPP_ERROR_STREAM(LOGGER, "Task planning failed");
        return;
    }

    try
    {
        task2.init();
    }
    catch (mtc::InitStageException& e)
    {
        RCLCPP_ERROR_STREAM(LOGGER, e);
        return;
    }
    if (!task2.plan(5))
    {
        RCLCPP_ERROR_STREAM(LOGGER, "Task planning failed");
        return;
    }

  return;
}

The above code causes a segfault in the collision checking of the IK wrapper for the second task and the following warning is very rarely given (I have only seen it once): [moveit_task_constructor_visualization.task_list_model]: unknown task: ... . This might not be the only situation this happens but I have no other examples that are simple or fail reliably. The other cases also didn't show the warning so I don't know if that is just something I did wrong. Changing the code such that the task2 = createTask(); line appears after the first one is initialised, or instead of being class members declaring the tasks like:

    mtc::Task task_ = createTask();
    mtc::Task task2 = createTask();

makes the segfault go away.

JSchaaf2 avatar Nov 30 '22 12:11 JSchaaf2