Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid segfault and improve error warnings #603

Closed
wants to merge 7 commits into from

Conversation

sjahr
Copy link
Contributor

@sjahr sjahr commented Aug 12, 2024

Check for nullptr in computeIK and print warnings when returning a nullptr

Copy link
Contributor

@rhaschke rhaschke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't yet see the need for these extra checks. Can you please elaborate on your error condition.

capabilities/src/execute_task_solution_capability.cpp Outdated Show resolved Hide resolved
core/src/container.cpp Outdated Show resolved Hide resolved
@@ -314,6 +314,11 @@ void ComputeIK::compute() {

link = scene->getCurrentState().getRigidlyConnectedParentLinkModel(ik_pose_msg.header.frame_id);

if (!link) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

knowsFrameTransform(), a few lines above, should have validated that the frame exists.
Under what circumstances do you run into a segfault here?
I cannot imagine a valid frame that returns NULL here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There seem to be cases under which getRigidlyConnectedParentLinkModel returns a nullptr. Are they all covered by knowsFrameTransform?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if I am understanding it correctly. I tried to add comments to the code to make it more comprehensible in https://github.com/moveit/moveit2/pull/2969/files. Do you think they are accurate? My current understanding is that this function returns a nullptr when there is nothing connected to the parent or when the transform between the parent body and the given frame is unknown.

Copy link
Contributor

@rhaschke rhaschke Aug 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There seem to be cases under which getRigidlyConnectedParentLinkModel returns a nullptr. Are they all covered by knowsFrameTransform?

Yes, they should be covered by knowsFrameTransform. If not, that's probably a bug. Please state your concrete problem.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My current understanding is that this function returns a nullptr when there is nothing connected to the parent or when the transform between the parent body and the given frame is unknown.

IMO, this function should return NULL only if the given frame is unknown. Note that this function finds the parent link, which frame is connected to.

@@ -314,6 +314,11 @@ void ComputeIK::compute() {

link = scene->getCurrentState().getRigidlyConnectedParentLinkModel(ik_pose_msg.header.frame_id);

if (!link) {
RCLCPP_WARN_STREAM(
LOGGER, fmt::format("ik frame '{}' is not rigidly connected to any link", ik_pose_msg.header.frame_id));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message doesn't make sense: an existing frame needs to be connected to some link.

core/src/stages/compute_ik.cpp Outdated Show resolved Hide resolved
@@ -314,6 +314,11 @@ void ComputeIK::compute() {

link = scene->getCurrentState().getRigidlyConnectedParentLinkModel(ik_pose_msg.header.frame_id);

if (!link) {
RCLCPP_WARN_STREAM(
LOGGER, fmt::format("ik frame '{}' is not rigidly connected to any link", ik_pose_msg.header.frame_id));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this be more precise?

Suggested change
LOGGER, fmt::format("ik frame '{}' is not rigidly connected to any link", ik_pose_msg.header.frame_id));
LOGGER, fmt::format("ik frame '{}' is not connected to any parent link", ik_pose_msg.header.frame_id));

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I said, I expect this to return NULL if and only if frame doesn't exist. Do you have other evidence?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sjahr: I'm still curious to learn about your concrete issue.
In which case does getRigidlyConnectedParentLinkModel returns NULL, which is not handled before by knowsFrameTransform?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I cannot share more info on this at the moment 😞 I'll try debugging it further and hopefully figure out what the real source behind this is.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not expecting a detailed error analysis, but ideally a code snippet reproducing your segfault - I assume you observed a segfault in some code.

Copy link
Contributor Author

@sjahr sjahr Aug 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, unfortunately I don't have access to the code that causes the error and it seems to happen only in a HW setup. If you'd prefer that I can close this PR for now and come back later with more solid changes.

@sjahr sjahr requested a review from rhaschke August 12, 2024 12:29
@@ -46,7 +46,7 @@
#include <fmt/format.h>

namespace {

const rclcpp::Logger LOGGER = rclcpp::get_logger("moveit_task_constructor_visualization.execute_task_solution");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert those changes too.

core/src/container.cpp Outdated Show resolved Hide resolved
@sjahr
Copy link
Contributor Author

sjahr commented Aug 26, 2024

Closing this for now and I'll open a PR / issue when I have a better understanding of the problem or a solution. Thanks for your feedback!

@sjahr sjahr closed this Aug 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants