Ask Your Question

"Assertion `!pthread_mutex_lock(&m)' failed." runtime error while working with custom message and kinect

asked 2011-07-25 02:02:17 -0500

kluessi gravatar image

updated 2011-07-26 07:37:29 -0500

Hi all,

I'm working with the Microsoft Kinect.

I'm using pointcloud_to_laserscan to retrieve a laserscan from kinect.

And there is another node which retrieves the rgb image from kinect for feature extraction and advertises the features using a custom ros message on a topic called "features".

Now I have another node. This node should subscribe to the pointcloud_to_laserscan and to the features topic using message_filters, because I need the laserscan and the features taken at the same time.

I tried to use the tutorial on

I defined a sync policy:

typedef message_filters::sync_policies::ApproximateTime<sensor_msgs::LaserScan, myNode::myMsg> SyncLaserNodePolicy;

message_filters::Synchronizer<SyncLaserNodePolicy> sync2_;
message_filters::Subscriber<sensor_msgs::LaserScan> kinectLaser_sub;
message_filters::Subscriber<myNode::myMsg> feature_sub;

In the constructor of the node I initialize:


My custom message is defined as:

Header header
surfKeyp2d[] keypoints2d
surfKeyp3d[] keypoints3d
surfDescMsg[] descriptors
uint32 number
sensor_msgs/Image image
geometry_msgs/TransformStamped trans

The code is compiling without errors, but when I try to run my node I get the following error:

myNode: /usr/include/boost/thread/pthread/mutex.hpp:50: 
void boost::mutex::lock():     Assertion `!pthread_mutex_lock(&m)' failed.

Anybody have an idea whats wrong?

Thanks a lot!

edit retag flag offensive close merge delete

3 answers

Sort by ┬╗ oldest newest most voted

answered 2011-07-26 07:12:06 -0500

Dariush gravatar image

Do you see any warnings while compiling this code? I would expect some warnings about the order in which you are initializing your class members.

In C++ member variables are initialized according the order of declaration, not the order you choose in the constructor. As you have declared the Sychronizer first, it's constructor will be called with uninitialized subscribers. That can cause all kind of nasticities, including the one you observed.

cheers Dariush

edit flag offensive delete link more

answered 2011-07-26 07:37:04 -0500

Try getting a stack trace for the crashing node either by running it in gdb or setting the ulimit -c unlimited to get the OS to produce a core.

With the stack trace you'll be able to tell exactly where it crashes.

edit flag offensive delete link more

answered 2011-08-01 19:19:51 -0500

kluessi gravatar image

Thanks for the replies.

I changed the order of initialization as mentioned by Dariush and it worked. Thx again.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2011-07-25 02:02:17 -0500

Seen: 3,361 times

Last updated: Aug 01 '11