Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segmentation fault in ros::Time::now () at /home/perc/workspace/RealsenseSDK_Gated_master #2645

Closed
omerbrandis opened this issue Oct 31, 2018 · 15 comments
Assignees

Comments

@omerbrandis
Copy link

Dear support,

I have an application written in c++ that uses libreasense sdk v 2.16.1 ( the latest available )
AND ros kenetic ( indipendently from its use by librealsense).
(ubuntu 16.04)

while i was using a "older" version of ros kenetic everything worked well,
but now i was forced to update my installation of ros kenetic to the latest one available
( ros core shows i'm now running version 1.12.14 ( used to be 1.12.12 ))
and now my application crashes when I send it a ros message to a topic its listening on.
in other works, i have not changed my code, i only updated my installation of ros and now my application crashes.

here is the back trace in for core file generated
it shows the problem to be in librealsense.

#0 0x00007f689dc2c410 in ros::Time::now () at /home/perc/workspace/RealsenseSDK_Gated_master__Debian_CreatePackage_xenial/src/third-party/realsense-file/rosbag/rostime/src/time.cpp:261
#1 0x00007f689e73bd6a in ros::Subscription::handleMessage(ros::SerializedMessage const&, bool, bool, boost::shared_ptr<std::map<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, std::__cxx11::basic_string<char, std::char_traits, std::allocator >, std::less<std::__cxx11::basic_string<char, std::char_traits, std::allocator > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits, std::allocator > const, std::__cxx11::basic_string<char, std::char_traits, std::allocator > > > > > const&, boost::shared_ptrros::PublisherLink const&) () from /opt/ros/kinetic/lib/libroscpp.so
#2 0x00007f689e717beb in ros::TransportPublisherLink::handleMessage(ros::SerializedMessage const&, bool, bool) () from /opt/ros/kinetic/lib/libroscpp.so
#3 0x00007f689e717729 in ros::TransportPublisherLink::onMessage(boost::shared_ptrros::Connection const&, boost::shared_array const&, unsigned int, bool) ()
from /opt/ros/kinetic/lib/libroscpp.so
#4 0x00007f689e69924b in ros::Connection::readTransport() () from /opt/ros/kinetic/lib/libroscpp.so
#5 0x00007f689e71278a in ros::TransportTCP::socketUpdate(int) () from /opt/ros/kinetic/lib/libroscpp.so
#6 0x00007f689e74f4f0 in ros::PollSet::update(int) () from /opt/ros/kinetic/lib/libroscpp.so
#7 0x00007f689e6d4ac5 in ros::PollManager::threadFunc() () from /opt/ros/kinetic/lib/libroscpp.so
#8 0x00007f68826e55d5 in ?? () from /usr/lib/x86_64-linux-gnu/libboost_thread.so.1.58.0
#9 0x00007f689dfb46ba in start_thread (arg=0x7f68541e7700) at pthread_create.c:333
#10 0x00007f688325941d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

I was unable to perform ros downgrade.

please advise.
Omer Brandis.

@MartyG-RealSense
Copy link
Collaborator

Would it be possible for you to try the latest 2.16.3 SDK and see if it makes a difference to your problem? It contains a ROS build fix for Debian packages.

https://github.com/IntelRealSense/librealsense/releases/tag/v2.16.3

@dorodnic dorodnic added the ros label Oct 31, 2018
@omerbrandis
Copy link
Author

  1. can you please provide more information regarding "ROS build fix using debian packages" ?

  2. can you tell me which version of ros was used to "build" realsense versions 1.16.1 and 1.16.3 respectively ?

thanks,
Omer

@MartyG-RealSense
Copy link
Collaborator

MartyG-RealSense commented Oct 31, 2018

That one-line description is all the information I have about the ROS build fix in 2.16.3, unfortunately.
One of the Intel members on this forum can provide further details (I do not work for Intel).

The most recent version of the ROS wrapper, updated September 27 2018, states that it supports ROS Kinetic distributions. Again, Intel can provide an official answer to that question about which ROS version they use.

@omerbrandis
Copy link
Author

the documentation for v 1.16.3 is
"This version is a hotfix for v2.16.2 that addresses the following"
I'm not using 2.16.2 , so it seems to me that 1.16.3 is not relevant.
1.16.1 is labeled as PRODUCTION which means it should be a very stable release, i'd rather avoid the non stable ones ...

:-)
Omer.

@omerbrandis
Copy link
Author

tested realsense version 2.16.3 - same result :-(

Omer

@MartyG-RealSense
Copy link
Collaborator

Thanks for trying 2.16.3. I'm sorry that doing so did not resolve your problem. Hopefully the Intel team on this forum will be able to lead you towards a solution.

@philipjames44
Copy link

@omerbrandis can you post the code segment that causes the issue?

@omerbrandis
Copy link
Author

Hello,

I Can't post the code segment.
It does not occur In my code.
I have posted the stack trace, it shows the error to be in librealsense.

Omer.

@dsharma2701
Copy link

I have the same issue, it occurs when am trying to subscribe for multiple messages, it segfaults on L261 or L255 time.cpp (https://github.com/IntelRealSense/librealsense/blob/master/third-party/realsense-file/rosbag/rostime/src/time.cpp)

message_filters::Subscriber<sensor_msgs::CameraInfo> color_cam_info_sub(nh, "/camera/color/camera_info", 5);
message_filters::Subscriber<sensor_msgs::Image> depth_image_sub(nh, "/camera/aligned_depth_to_color/image_raw", 5);
message_filters::Subscriber<sensor_msgs::Image> color_image_sub(nh, "/camera/color/image_raw", 5);

typedef sync_policies::ApproximateTime<sensor_msgs::Image, sensor_msgs::Image, sensor_msgs::CameraInfo> MySyncPolicy;
std::cout << "Declaring policy ...." << std::endl;
// TimeSynchronizer<sensor_msgs::Image, sensor_msgs::Image, sensor_msgs::CameraInfo> sync(depth_image_sub, color_image_sub, color_cam_info_sub, 10);
Synchronizer<MySyncPolicy> sync(MySyncPolicy(10), depth_image_sub, color_image_sub, color_cam_info_sub);
std::cout << "Registering call back  ...." << std::endl;
async.registerCallback(boost::bind(&imageExtractedGround, _1, _2, _3));
std::cout << "Binding done ... " << std::endl;
std::cout << "Callback Registered!" << std::endl;

here is the stack trace -
#0 0x00007ffff77d619a in ros::Time::now ()
at /home/divya/catkin_ws/src/test_real_sense/librealsense/third-party/realsense-file/rosbag/rostime/src/time.cpp:255
#1 0x00007ffff4bb4d6a in ros::Subscription::handleMessage(ros::SerializedMessage const&, bool, bool, boost::shared_ptr<std::map<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, std::__cxx11::basic_string<char, std::char_traits, std::allocator >, std::less<std::__cxx11::basic_string<char, std::char_traits, std::allocator > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits, std::allocator > const, std::__cxx11::basic_string<char, std::char_traits, std::allocator > > > > > const&, boost::shared_ptrros::PublisherLink const&) () from /opt/ros/kinetic/lib/libroscpp.so
#2 0x00007ffff4b90beb in ros::TransportPublisherLink::handleMessage(ros::SerializedMessage const&, bool, bool) ()
from /opt/ros/kinetic/lib/libroscpp.so
#3 0x00007ffff4b90729 in ros::TransportPublisherLink::onMessage(boost::shared_ptrros::Connection const&, boost::shared_array const&, unsigned int, bool) () from /opt/ros/kinetic/lib/libroscpp.so
#4 0x00007ffff4b1224b in ros::Connection::readTransport() () from /opt/ros/kinetic/lib/libroscpp.so
#5 0x00007ffff4b8b78a in ros::TransportTCP::socketUpdate(int) () from /opt/ros/kinetic/lib/libroscpp.so
#6 0x00007ffff4bc84f0 in ros::PollSet::update(int) () from /opt/ros/kinetic/lib/libroscpp.so
#7 0x00007ffff4b4dac5 in ros::PollManager::threadFunc() () from /opt/ros/kinetic/lib/libroscpp.so
#8 0x00007fffed36d5d5 in ?? () from /usr/lib/x86_64-linux-gnu/libboost_thread.so.1.58.0
#9 0x00007ffff442c6ba in start_thread (arg=0x7fffd6161700) at pthread_create.c:333
#10 0x00007ffff1ebf41d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109
(gdb) quit

@dsharma2701
Copy link

@omerbrandis i was able to resolve it by putting real sense library last in the order of linked libraries.
I dug in the code and it seems like librealsense is redefining the ros::Time::now() under thirdparty, not sure why same namespace was used ? Since the linkage was going there it segfaults, if you declare the linkage order to have ROS libs be the priority then you can work around it.

@omerbrandis
Copy link
Author

omerbrandis commented Nov 7, 2018 via email

@chaoli2
Copy link

chaoli2 commented Nov 13, 2018

@dsharma2701 @omerbrandis
I have the same issue in my ROS project. I also write a minimal ROS package to clarify the problem.

It seems that changing linkage order works only if you do not use rs API. For example, if you use second linkage order defined in my CMakeLists.txt, segmentation fault occurs only if you use rs API, like here in main.cpp. If no rs API is used, this workaround helps.

Unfortunately, this workaround doesn't work in my ROS project. So I expect maintainers' kindly help to resolve this issue fundamentally. @RealSense-Customer-Engineering Thanks very much.

@dorodnic dorodnic added the bug label Nov 13, 2018
@dorodnic
Copy link
Contributor

I agree this is a problem.
Since we need parts of ROS infrastructure for LRS recording capabilities, but do not want to make ROS packages a strict dependency of librealsense, there is no trivial fix. This might be resolved via a simple "put everything in namespace" solution, but we need to look into it more closely.

@andre-ryll
Copy link

I recently came across this issue as well. The link order when using ros and catkin seems to be random, so a special order is not a viable solution. I tried "put everything in a namespace" and it actually works quite well. I have renamed all occurences of "ros" to "rs2rosinternal" with some sed magic.

You can run the following commands to do the same (in the librealsense top-level folder):
find ./ -type f -exec sed -i 's/using\ ros/using\ rs2rosinternal/g' {} \;
find ./ -type f -exec sed -i 's/ros\:\:/rs2rosinternal\:\:/g' {} \;
find ./ -type f -exec sed -i 's/namespace\ ros\b/namespace\ rs2rosinternal/g' {} \;

If you want to automate it and use it in a script a slightly more escaped version is needed:
find ./ -type f -exec sed -i "s/using\\ ros/using\\ rs2rosinternal/g" {} +
find ./ -type f -exec sed -i "s/ros\\:\\:/rs2rosinternal\\:\\:/g" {} +
find ./ -type f -exec sed -i "s/namespace\\ ros\\b/namespace\\ rs2rosinternal/g" {} +

Hope that helps.

dorodnic added a commit to dorodnic/librealsense that referenced this issue Nov 28, 2018
dorodnic added a commit to dorodnic/librealsense that referenced this issue Nov 28, 2018
@dorodnic
Copy link
Contributor

Should be resolved in 2.17.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants