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

Revision history [back]

There are some strange things in you code which may be causing problems sometimes. I would expect you to be getting compiler warnings from them too.

m.num_bytes - (m.message_start - m.buf.get())

This expression in the definition of s is very unusual. You're doing arithmetic with pointers and a size_t this is not recommended. You're subtracting the pointer for the shared_array data from the pointer to the message, they are probably the same address most of the time which will make this term zero however they may occasionally be different. In this case you're calculating the difference between these two pointers in memory a largely meaningless value. What was the purpose of this piece of code?

I would recommend using this and seeing if it helps:

ros::serialization::IStream s(m.message_start, m.num_bytes);

It might help to print out some debugging information containing the size of the message so you can see if this causes the crash or not too.

Hope this helps.