ROS multi thread c++
I developed two separate program and tested them. One program is for socket communication with external network the other one is for internal ros work. But then I add the first program as thread into ROS package and run the program I get this error:
Error message is that "malloc.c:2451: sYSMALLOc: Assertion '(old_top == (((mbinptr) (((char *) &((av)->bins[((1) - 1)*2])) -
__builtin_offsetof (struct malloc_chunk, fd)))) && old_size == 0)"
I couldn't find any solution on the internet. Here is my source code and I omitted some not important parts. By removing line by lime I localized that the cause of error is in this line "SocketAddress sa(IPAddress(), 50000);". The error though appear right at the beginning of the program so I can really debug it. I guess the error is related to stack memory.
please help me.
using namespace std;
using namespace Poco::XML;
using namespace Poco::Net;
namespace enc = sensor_msgs::image_encodings;
AutoPtr<Document> pDoc;
sensor_msgs::CameraInfo info_cam;
std::vector<cv::Point> platform_corners(NUMBER_OF_CORNERS);
image_transport::Publisher pub_cropped;
class HelloRunnable: public Poco::Runnable{
virtual void run(){
SocketAddress sa(IPAddress(), 50000);
DatagramSocket sock(sa);
//other code
}
};
}
int main (int argc, char** argv){
int i = 0;
HelloRunnable runnable;
Poco::Thread thread;
thread.start(runnable);
thread.join();
ros::init (argc, argv, "locateCamera");
ros::NodeHandle nh;
boost::shared_ptr<image_transport::ImageTransport> it_(boost::shared_ptr<image_transport::ImageTransport>(new image_transport::ImageTransport(nh)));
ros::Subscriber sub = nh.subscribe ("/ar_pose_marker", 1, &getCornersInPixCB);
ros::Subscriber sub_info_l = nh.subscribe("/camera/camera_info", 1, &getCamInfoCb);
ros::spin ();
}