Skip to content
This repository was archived by the owner on May 31, 2025. It is now read-only.
This repository was archived by the owner on May 31, 2025. It is now read-only.

ROS_ASSERT_MSG check on md5_sum of publish is ignored in release modes. #2095

@tahsinkose

Description

@tahsinkose

Not the same issue in #1972, but the root cause is the same. CMake release modes skip assertion checks by implicitly specifying -NDEBUG flag, hence the check in https://github.com/ros/ros_comm/blob/noetic-devel/clients/roscpp/include/ros/publisher.h#L81 gets skipped. This allows the successful compilation of the following:

...
ros::Publisher chatter_pub = n.advertise<std_msgs::String>("chatter", 1000);
std_msgs::String msg;
msg.data = "hello world ";
std::vector<std_msgs::String> msgs{msg};
chatter_pub.publish(msgs);
...

In my case, the subscriber receives an empty std_msgs/String.

The rationale in http://wiki.ros.org/CppStyleGuide is given as:
"It is typical to develop software with assertion-checking enabled, in order to catch violations. When nearing software completion and when assertions are found to always be true in the face of extensive testing, you build with a flag that removes assertions from compilation, so they take up no space or time."

It is reasonable as all pub/sub relationships should be unit tested. However such testing is very non-trivial and tedious in some cases. Therefore I think that this particular check should not be skipped in release modes, which would facilitate the detection of such type erasure failures on published messages.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions