ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Callback not getting triggered when running with valgrind

asked 2023-02-22 04:28:12 -0500

SamRodriguez gravatar image

I want to profile multiple nodes in my system, I've already profiled a few nodes successfully by adding the valgrind prefix like so:

def generate_launch_description():
    return LaunchDescription([
        Node(
            package="fov_filtering",
            namespace='',
            executable="fov_filtering_app",
            name="fov_filtering_node",
            output="screen",
            prefix=['valgrind --tool=callgrind'],

The steps I follow are the following:

  1. Build relevant packages with Debug flag
  2. Run relevant rosbag with the data that the callback subscribes to
  3. Run the launch file with the valgrind prefix
  4. Stop nodes and visualize the callgrind file in kcachegrind

I am printing out a message to the console everytime the callbacks get triggered as a sanity check. For some mysterious reason the callback of some nodes is not triggered. I am sure that all the parameters and topic names are correct because I am copy-pasting the regular launch file into a new one with the prefix "profiling_" which only differs in the prefix added.

For reference, this is the signature and binding of a callback which is getting triggered:

subscriber_ = this->create_subscription<sensor_msgs::msg::PointCloud2>("/radar/input/cloud", 10, 
std::bind(&RadarTrackingNode::callback, this, std::placeholders::_1));
...
void RadarTrackingNode::callback(const sensor_msgs::msg::PointCloud2::SharedPtr cloud)

And this is the signature and binding of a callback which is not getting triggered:

subscription_ = this->create_subscription<sensor_msgs::msg::PointCloud2>(pointcloud_topic, 20, std::bind(&Main::_callback, this, std::placeholders::_1));
...
void Main::_callback(const sensor_msgs::msg::PointCloud2::SharedPtr sensor_point_cloud);

To be clear I can see the callgrind file, the problem is that since the callback is never triggered I don't see it in the call graph. Any ideas of what can be the source of the problem or what can I try to solve it?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2023-02-23 03:13:16 -0500

SamRodriguez gravatar image

updated 2023-02-23 03:46:12 -0500

It turns out that the callbacks that were not getting triggered are the ones expecting Lidar PointClouds which are too big for valgrind to load since it has a limited memory block for programs running on it. See their official documentation. The callbacks getting triggered where the ones expecting a radar point cloud which is much more lightweight.

The only solution is to

"change the 8 MB hardcoded limit and recompile Valgrind."

If I had added the -v flag (verbose) to the prefix like so prefix=['valgrind --tool=callgrind -v'], in the launch file, I would have seen the error

[profiling_node-1] ==56144== brk segment overflow in thread #1: can't grow to 0x48cd000
[profiling_node-1] ==56144== (see section Limitations in user manual)

Which would have saved me a lot of time to find the source of the problem.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2023-02-22 04:28:12 -0500

Seen: 258 times

Last updated: Feb 23 '23