Segmentation violation in nodeHandle.subscribe [closed]

asked 2012-12-13 18:56:20 -0600

swingingiant gravatar image

updated 2012-12-15 23:39:14 -0600

This code had been working earlier for my roscpp package. I integrated more code to this and have added a few C libraries but this code is a direct copy from the previous version. It fails everytime in {nh.subscribe}. I am using Ubuntu Linux 11.10 with ROS electric. I do not wish to move to a newer version of ROS at this juncture of development. I am getting a segmentation violation in the following code:

ros::init(argc, argv, "irobot_stargazer");
ros::NodeHandle nh; 
ros::Subscriber sub;
sub = nh.subscribe("/cu/stargazer_marker_cu", 1, get_stargazer_coord);
//sub2 = nh.subscribe("/destXYT", 10, get_destination);
if(!sub)
{// the subscribe did not work
    printf("could not subscribe to stargazer\n");
    exit(0);
}

the error shown in gdb says: 0x00123c3b in ?? () from /lib/ld-linux.so.2

Can someone please let me know if there is something I am missing or supposed to add.

Edit 1: I am putting the backtrace for the code: 0 0x00123c3b in ?? () from /lib/ld-linux.so.2

1 0x005573cf in XmlRpc::XmlRpcSocket::accept (fd=12) at /tmp/buildd/ros-electric-ros-comm-1.6.7/debian/ros-electric-ros-comm/opt/ros/electric/stacks/ros_comm/utilities/xmlrpcpp/src/XmlRpcSocket.cpp:165

2 0x00551719 in XmlRpc::XmlRpcServer::acceptConnection (this=0x80b1698) at /tmp/buildd/ros-electric-ros-comm-1.6.7/debian/ros-electric-ros-comm/opt/ros/electric/stacks/ros_comm/utilities/xmlrpcpp/src/XmlRpcServer.cpp:152

3 0x0055163f in XmlRpc::XmlRpcServer::handleEvent (this=0x80b1698) at /tmp/buildd/ros-electric-ros-comm-1.6.7/debian/ros-electric-ros-comm/opt/ros/electric/stacks/ros_comm/utilities/xmlrpcpp/src/XmlRpcServer.cpp:142

4 0x00551340 in XmlRpc::XmlRpcDispatch::work (this=0x80b16a4, timeout=0.10000000000000001) at /tmp/buildd/ros-electric-ros-comm-1.6.7/debian/ros-electric-ros-comm/opt/ros/electric/stacks/ros_comm/utilities/xmlrpcpp/src/XmlRpcDispatch.cpp:131

5 0x00552004 in XmlRpc::XmlRpcServer::work (this=0x80b1698, msTime=0.10000000000000001) at /tmp/buildd/ros-electric-ros-comm-1.6.7/debian/ros-electric-ros-comm/opt/ros/electric/stacks/ros_comm/utilities/xmlrpcpp/src/XmlRpcServer.cpp:132

6 0x001c6dbf in ros::XMLRPCManager::serverThreadFunc (this=0x80b1688) at /tmp/buildd/ros-electric-ros-comm-1.6.7/debian/ros-electric-ros-comm/opt/ros/electric/stacks/ros_comm/clients/cpp/roscpp/src/libros/xmlrpc_manager.cpp:258

7 0x001c92bb in operator() (p=<optimized out="">, this=0x80b45a4) ---Type <return> to continue, or q <return> to quit--- at /usr/include/boost/bind/mem_fn_template.hpp:49

8 operator()<boost::_mfi::mf0<void, ros::xmlrpcmanager="">, boost::_bi::list0> ( f=..., this=0x80b45ac, a=<optimized out="">) at /usr/include/boost/bind/bind.hpp:253

9 operator() (this=0x80b45a4) at /usr/include/boost/bind/bind_template.hpp:20

10 boost::detail::thread_data<boost::_bi::bind_t<void, boost::_mfi::mf0<void,="" ros::xmlrpcmanager="">, boost::_bi::list1<boost::_bi::value<ros::xmlrpcmanager*> > > >::run (this=0x80b44a0) at /usr/include/boost/thread/detail/thread.hpp:61

11 0x0059c3cc in thread_proxy () from /usr/lib/libboost_thread.so.1.46.1

12 0x003b3d31 in start_thread () from /lib/i386-linux-gnu/libpthread.so.0

13 0x0049a0ce in clone () from /lib/i386-linux-gnu/libc.so.6

Backtrace stopped: Not enough registers or memory available to unwind further

Here are the things that I have tried till now: 1. Initially created libraries by use of makefiles and called those makefiles through cmake. This ... (more)

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by tfoote
close date 2015-09-18 19:03:31.321908

Comments

Looks OK to me. Try to compile it as a single program without other libraries, then you know it is not this code which is the problem.

dornhege gravatar image dornhege  ( 2012-12-13 21:14:52 -0600 )edit

And please provide a more complete backtrace and maybe the definition of get_stargazer_coord.

Lorenz gravatar image Lorenz  ( 2012-12-13 23:00:39 -0600 )edit

I have ported the code to fuerte too but the same problem is cropping up.

swingingiant gravatar image swingingiant  ( 2012-12-15 18:13:50 -0600 )edit

I tested extensively with lots of different approaches and have narrowed down to the problem coming from ros::spinOnce(). I am guessing the error occurs every time I create the nodehandle and add a subscriber there is a call to ros::spinOnce implicitly which creates the problem.

swingingiant gravatar image swingingiant  ( 2012-12-16 14:58:08 -0600 )edit

can anyone please provide a solution to this open problem as I am unable to make a headway in this. I hope the ROS team can provide some inputs on this problem.

swingingiant gravatar image swingingiant  ( 2013-01-14 23:50:50 -0600 )edit

Currently it is not possible to provide a solution because the problem cannot be reproduced. The code you posted should work in principle, but is incomplete. Please provide a minimal complete example given the missing definitions.

dornhege gravatar image dornhege  ( 2013-01-15 00:51:59 -0600 )edit