noetic createTimer always segfault
Hi,
After introducing ROS to my program with success, i wanted to use it more and added timer.
I am using the same code on both Ubuntu20/noetic and Ubuntu18/melodic without any issue.
But with timer i have a problem. On melodic it works fine, on noetic it always segfault when i call createTimer.
I tried the sample in the wiki for timers and that simple code also segfaults. I tried with different ways of calling createTimer with different callback binding style but all segfaults.
void callback1(const ros::TimerEvent&) {
ROS_INFO("Callback 1 triggered");
}
int main(int argc, char **argv)
{
ros::init(argc, argv, "talker");
ros::NodeHandle n;
ros::Timer timer1 = n.createTimer(ros::Duration(0.1), callback1);
ros::spin();
return 0;
}
Some basics information
ROS_VERSION=1 ROS_PYTHON_VERSION=3
ROS_PACKAGE_PATH=/opt/ros/noetic/share
ROS_ETC_DIR=/opt/ros/noetic/etc/ros
ROS_MASTER_URI=http://localhost:11311
ROS_ROOT=/opt/ros/noetic/share/ros
ROS_DISTRO=noetic
noetic is installed with apt, all default packages on a new fresh install of Ubuntu20 server All parameters to start roscore or my test program are defaults.
Stack trace is not useful but i have no idea how i could have more details at one line it is actually crashing inside libroscpp
#0 0x00007ffff7f0a36e in ros::NodeHandle::createTimer(ros::Duration, boost::function<void (ros::TimerEvent const&)> const&, bool, bool) const () from /lib/x86_64-linux-gnu/libroscpp.so.2d
#1 0x0000555555558b97 in main (argc=1, argv=0x7fffffffe1e8) at /home/worker/main.cpp:11
To install i do
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -
sudo apt install ros-noetic-ros-base libroscpp-dev
To compile my code, i use cmake and link to roscpp using
pkg_check_modules(libros REQUIRED roscpp)
target_include_directories(mybin PUBLIC ${libros_INCLUDE_DIRS})
target_link_libraries(mybin ${libros_LIBRARIES})
Thanks for your help.