Robotics StackExchange | Archived questions

Very rare crash in ROS spinner thread inside Publisher::publish

I am publishing a message with a standard ros::Publisher. At one point I got a crash, which occurred outside my own thread!

I know for sure that the publisher hasn't gone out of scope at the time of crash. But the message object DOES go out-of-scope, since it is locally created and fed to publisher:

  static void StopFocus(const std::string &client_id) {
    aeolus_nav_msgs::TrajectoryGeneratorHeader msg;
    msg.client_id = client_id;
    msg.priority = FocusPriority::REMOVE;
    to_generator.publish(msg); // standard ros::Publisher
  }

I am sure message going out of scope is not the issue... What could the problem be? Can anyone help me please? 🙏 🙏 🙏

A got a backtrace of the crash, and it's like:

Thread 1 (Thread 0x7f727effd700 (LWP 1272)):
#0  0x00007f72cbdc6eb0 in __memmove_avx_unaligned_erms ()
    at ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:371
#1  0x00007f72d8283966 in memcpy (__len=<optimized out>, __src=<optimized out>, __dest=<optimized out>)
    at /usr/include/x86_64-linux-gnu/bits/string_fortified.h:34
#2  0x00007f72d8283966 in ros::serialization::Serializer<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::write<ros::serialization::OStream>(ros::serialization::OStream&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (str="", stream=<synthetic pointer>...) at /opt/ros/melodic/include/ros/serialization.h:245
#3  0x00007f72d8283966 in ros::serialization::serialize<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, ros::serialization::OStream>(ros::serialization::OStream&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (t="", stream=<synthetic pointer>...) at /opt/ros/melodic/include/ros/serialization.h:154
#4  0x00007f72d8283966 in ros::serialization::OStream::next<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (t="", this=<synthetic pointer>) at /opt/ros/melodic/include/ros/serialization.h:747
#5  0x00007f72d8283966 in ros::serialization::Serializer<nav_msgs::TrajectoryGeneratorHeader_<std::allocator<void> > >::allInOne<ros::serialization::OStream, nav_msgs::TrajectoryGeneratorHeader_<std::allocator<void> > const&>(ros::serialization::OStream&, nav_msgs::TrajectoryGeneratorHeader_<std::allocator<void> > const&) (m=..., stream=<synthetic pointer>...)
    at /opt/ros/melodic/include/nav_msgs/TrajectoryGeneratorHeader.h:189
#6  0x00007f72d8283966 in ros::serialization::Serializer<nav_msgs::TrajectoryGeneratorHeader_<std::allocator<void> > >::write<ros::serialization::OStream, nav_msgs::TrajectoryGeneratorHeader_<std::allocator<void> > >(ros::serialization::OStream&, nav_msgs::TrajectoryGeneratorHeader_<std::allocator<void> > const&) (t=..., stream=<synthetic pointer>...)
    at /opt/ros/melodic/include/nav_msgs/TrajectoryGeneratorHeader.h:195
#7  0x00007f72d8283966 in ros::serialization::serialize<nav_msgs::TrajectoryGeneratorHeader_<std::allocator<void> >, ros::serialization::OStream>(ros::serialization::OStream&, nav_msgs::TrajectoryGeneratorHeader_<std::allocator<void> > const&) (t=..., stream=<synthetic pointer>...)
    at /opt/ros/melodic/include/ros/serialization.h:154
#8  0x00007f72d8283966 in ros::serialization::serializeMessage<nav_msgs::TrajectoryGeneratorHeader_<std::allocator<void> > >(nav_msgs::TrajectoryGeneratorHeader_<std::allocator<void> > const&) (message=...)
    at /opt/ros/melodic/include/ros/serialization.h:815
#9  0x00007f72d8281e21 in boost::_bi::list1<boost::reference_wrapper<nav_msgs::TrajectoryGeneratorHeader_<std::allocator<void> > const> >::operator()<ros::SerializedMessage, ros::SerializedMessage (*)(nav_msgs::TrajectoryGeneratorHeader_<std::allocator<void> > const&), boost::_bi::list0>(boost::_bi::type<ros::SerializedMessage>, ros::SerializedMessage (*&)(nav_msgs::TrajectoryGeneratorHeader_<std::allocator<void> > const&), boost::_bi::list0&, long) (f=<optimized out>, a=<synthetic pointer>..., this=<optimized out>)
    at /usr/include/boost/bind/bind.hpp:249
#10 0x00007f72d8281e21 in boost::_bi::bind_t<ros::SerializedMessage, ros::SerializedMessage (*)(nav_msgs::TrajectoryGeneratorHeader_<std::allocator<void> > const&), boost::_bi::list1<boost::reference_wrapper<nav_msgs::TrajectoryGeneratorHeader_<std::allocator<void> > const> > >::operator()() (this=<optimized out>) at /usr/include/boost/bind/bind.hpp:1294
#11 0x00007f72d8281e21 in boost::detail::function::function_obj_invoker0<boost::_bi::bind_t<ros::SerializedMessage, ros::SerializedMessage (*)(nav_msgs::TrajectoryGeneratorHeader_<std::allocator<void> > const&), boost::_bi::list1<boost::reference_wrapper<nav_msgs::TrajectoryGeneratorHeader_<std::allocator<void> > const> > >, ros::SerializedMessage>::invoke(boost::detail::function::function_buffer&) (function_obj_ptr=...)
    at /usr/include/boost/function/function_template.hpp:138
#12 0x00007f72cec6aeb7 in ros::TopicManager::publish(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, boost::function<ros::SerializedMessage ()> const&, ros::SerializedMessage&) ()
    at /opt/ros/melodic/lib/libroscpp.so
#13 0x00007f72d8284afe in ros::Publisher::publish<nav_msgs::TrajectoryGeneratorHeader_<std::allocator<void> > >(nav_msgs::TrajectoryGeneratorHeader_<std::allocator<void> > const&) const (this=0x7f71b8104610, message=...)
    at /opt/ros/melodic/include/ros/publisher.h:118
#14 0x00007f72cec7f48e in ros::PeerConnDisconnCallback::call() ()
    at /opt/ros/melodic/lib/libroscpp.so
#15 0x00007f72cec8aa7f in ros::CallbackQueue::callOneCB(ros::CallbackQueue::TLS*) () at /opt/ros/melodic/lib/libroscpp.so
#16 0x00007f72cec8b80b in ros::CallbackQueue::callOne(ros::WallDuration) ()
    at /opt/ros/melodic/lib/libroscpp.so
#17 0x00007f72cece3115 in ros::AsyncSpinnerImpl::threadFunc() ()
    at /opt/ros/melodic/lib/libroscpp.so
#18 0x00007f72ccd85bcd in  ()
    at /usr/lib/x86_64-linux-gnu/libboost_thread.so.1.65.1
#19 0x00007f72d24d86db in start_thread (arg=0x7f727effd700)
    at pthread_create.c:463
#20 0x00007f72cbd59a3f in clone ()
    at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Asked by billkotsias on 2020-11-05 09:56:30 UTC

Comments

You don't show the actual crash. I'm guessing it's a SEGFAULT?

Asked by gvdhoorn on 2020-11-05 12:16:17 UTC

That is correct

Asked by billkotsias on 2020-11-05 12:21:08 UTC

I doubt anyone will be able to say anything about this without reproducing it and then stepping in a debugger.

One possible cause could be that str="", but len!=0. But why that would be the case I have no idea.

Asked by gvdhoorn on 2020-11-05 12:28:17 UTC

Answers