boost: mutex lock failed in pthread_mutex_lock: Invalid argument
Hi,
I met this error while executing my code. I'm on ROS Melodic. It regards only a specific node in a complex system with many nodes and threads. This is what I got from dbg:
[...]
Starting program: /home/alberto/tiago_dual_public_ws/devel/lib/new_policies_system/PolicyManager __name:=PolicyManager __log:=/home/alberto/.ros/log/5c077000-e004-11eb-9f34-d8cb8abf4555/PolicyManager-11.log
[tcsetpgrp failed in terminal_inferior: Inappropriate ioctl for device]
[tcsetpgrp failed in terminal_inferior: Invalid argument]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[tcsetpgrp failed in terminal_inferior: Invalid argument]
[New Thread 0x7fffd8053700 (LWP 16673)]
[New Thread 0x7fffd7852700 (LWP 16674)]
[New Thread 0x7fffd5051700 (LWP 16675)]
[tcsetpgrp failed in terminal_inferior: Invalid argument]
[New Thread 0x7fffd063e700 (LWP 16677)]
[New Thread 0x7fffcfe3d700 (LWP 16678)]
[New Thread 0x7fffcf63c700 (LWP 16679)]
[New Thread 0x7fffcee3b700 (LWP 16680)]
[New Thread 0x7fffce63a700 (LWP 16681)]
[ INFO] [1625766949.385975566, 375.938000000] [/PolicyManager]: Add a Continuous Input policy
[ WARN] [1625766949.412755082, 375.941000000] [/PolicyManager]: [input_policy] Updated dispersion to: 2.000000
[ WARN] [1625766949.412909993, 375.941000000] [/PolicyManager]: [input_policy] Updated distance to: 1.500000
[ INFO] [1625766949.427769591, 375.944000000] [/PolicyManager]: ALIVE (method)...
[ INFO] [1625766949.427897879, 375.944000000] [/PolicyManager]: ALIVE (main)...
[ INFO] [1625766949.428006993, 375.945000000] [/PolicyManager]: Add a Motion Prediction policy
[ WARN] [1625766949.443340894, 375.947000000] [/PolicyManager]: [motion_estimation_policy] Updated dt to: 1.000000
[ WARN] [1625766949.443447127, 375.947000000] [/PolicyManager]: [motion_estimation_policy] Updated angular STD to: 0.400000
[ WARN] [1625766949.443509621, 375.947000000] [/PolicyManager]: [motion_estimation_policy] Updated transform listening rate to: 30.000000
[New Thread 0x7fffcde39700 (LWP 16682)]
[New Thread 0x7fffcd638700 (LWP 16684)]
terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::lock_error> >'
what(): boost: mutex lock failed in pthread_mutex_lock: Invalid argument
Thread 10 "PolicyManager" received signal SIGABRT, Aborted.
[Switching to Thread 0x7fffcde39700 (LWP 16682)]
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
51 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb)
[...]
Can someone help me? I really don't know where to start.
The error indicates that you are using the wrong version of the boost library, or something it depends on. That is, there is some mismatch between the library version when the ros package was compiled and now, when it is being run.
You could try rebuilding the package and see if that fixes it.
If you upgraded your Ubuntu OS to a later major number, you need to install the matching release of ros and you need to rebuild all of your custom packages.
This might be due to a callback queue or spinner being destructed before a subscriber get's unsubscribed (or destructed). Hard to say without a code sample.