thanks for the suggestion.
we have modified the ROS1 to make it realtime according to ROS2, but for some 
reasons, we keep the roscore master node, so can you give some advice how to 
deploy the roscore ? should we deployed the roscore to primary domain or 
secondary domain? Now deploying it to primary domain has this bug, thanks.

发件人:Mariusz Janiak
收件人:Greg Gallagher,gengdongjiu,
抄 送,
时间:2018-07-12 18:52:06
主 题:Odp: Re: [Xenomai] [roscore issue for "Operation not permitted"] 
pthread_mutex_lock failed: operation not permitted

Dnia 12 lipca 2018 10:55 gengdongjiu <> napisał(a):

Hi Greg,
 Thanks for the answer,

On 2018/7/11 22:09, Greg Gallagher wrote:
Have you looked at any of the ROS frameworks that use Xenomai?  Is the
expectation that roscore runs in the secondary domain and your ros
based application runs in the primary domain?

Yes, we have looked at the the ROS frameworks that use Xenomai. do you have any 

Please consider OROCOS for RT part instead of ROS. Eventually ROS2.

we are not very familiar with the ROS.
In our test, we used the ROS pub and sub to do communication. From our test, if 
roscore runs in the secondary (normal linux)domain, it will not have such issue.
should the roscore run in the  secondary domain or the primary domain? I do not 
know which domain it should run into. thanks a lot.

ROS haven't been designed as a real-time framework, especially in communication 
domain (ros topics + TCP + XML RPC).



On Wed, Jul 11, 2018 at 10:03 AM, gengdongjiu <> wrote:
Hi, Philippe/ Gilles/ Jan/ Alexis/others,

I’m running ros on Xenomai, with Xenomai-3.07 and linux kernel 4.4.71. I
first export CFLAGS and LDFLAGS of posix skin. And compile ros project with
posix skin successfully.

Then, I run roscore as root user, it throws a std::system_error. So I debug
roscore with gdb. According to the gdb backtrace frame #10, it’s the 62
lines of participant.cpp that caused the problem. Which is
“std::unique_lock<std::mutex> ul(_msg_lock);”. As far as I know,
initializing a unique_lock will call _msg_lock.lock(),and _msg_lock is a
std::mutex, _msg_lock.lock() will call pthread_mutex_lock(). According the
to the error message “Operation not permitted”. Pthread_mutex_lock() must
return EPERM, and pthread_mutex_lock return EPRM only if the mutex is not
process-shared and does not belong to the current process or the caller
context is invalid.

So my question is why compiling and running ros on xenomai will cause
pthread_mutex_lock() return EPERM? Does current calling context is invalid ?
And how can I solve this problem, does anybody have any insight? By the way,
it’s perfect fine to compiling and running ros on linux with the same code.



root@ros:/home/ros/zjw/ros/install/ros_x86_64/lib# roscore

terminate called after throwing an instance of 'std::system_error'

 what():  Operation not permitted

Aborted (core dumped)

(gdb) r `which roscore`

Starting program: /usr/bin/python `which roscore`

[Thread debugging using libthread_db enabled]

Using host libthread_db library "/lib/x86_64-linux-gnu/".

[New Thread 0x7ffff3586700 (LWP 29315)]

[New Thread 0x7ffff279b700 (LWP 29316)]

[New Thread 0x7ffff1f9a700 (LWP 29317)]

[New Thread 0x7ffff1799700 (LWP 29318)]

[New Thread 0x7ffff0f98700 (LWP 29319)]

[New Thread 0x7fffe3fff700 (LWP 29320)]

[New Thread 0x7fffe37fe700 (LWP 29321)]

[New Thread 0x7fffe2ffd700 (LWP 29322)]

terminate called after throwing an instance of 'std::system_error'

 what():  Operation not permitted

Thread 9 "python" received signal SIGABRT, Aborted.

[Switching to Thread 0x7fffe2ffd700 (LWP 29322)]

0x00007ffff7825428 in __GI_raise (sig=sig@entry=6) at

54      ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.

(gdb) bt

#0  0x00007ffff7825428 in __GI_raise (sig=sig@entry=6) at

#1  0x00007ffff782702a in __GI_abort () at abort.c:89

#2  0x00007ffff3e6884d in __gnu_cxx::__verbose_terminate_handler () at

#3  0x00007ffff3e666b6 in __cxxabiv1::__terminate (handler=<optimized out>)
at ../../../../src/libstdc++-v3/libsupc++/

#4  0x00007ffff3e66701 in std::terminate () at

#5  0x00007ffff3e66919 in __cxxabiv1::__cxa_throw
(obj=obj@entry=0x7fffd00010d0, tinfo=0x7ffff414ec00 <typeinfo for
std::system_error>, dest=0x7ffff3e91640

   at ../../../../src/libstdc++-v3/libsupc++/

#6  0x00007ffff3e8f7fe in std::__throw_system_error (__i=1) at

#7  0x00007ffff4162451 in std::mutex::lock (this=0x25c7280) at

#8  std::unique_lock<std::mutex>::lock (this=0x7fffe2ffc300) at

#9  std::unique_lock<std::mutex>::unique_lock (__m=..., this=0x7fffe2ffc300)
at /usr/include/c++/5/mutex:415

#10 ros::Participant::read_msg[abi:cxx11]() (this=0x25c7200) at

#11 0x00007ffff4be9195 in _wrap_Participant_read_msg () from

#12 0x00000000004bc3fa in PyEval_EvalFrameEx ()

#13 0x00000000004c136f in PyEval_EvalFrameEx ()

#14 0x00000000004b9ab6 in PyEval_EvalCodeEx ()

#15 0x00000000004d55f3 in ?? ()

#16 0x00000000004a577e in PyObject_Call ()

#17 0x00000000004bed3d in PyEval_EvalFrameEx ()

#18 0x00000000004c136f in PyEval_EvalFrameEx ()

#19 0x00000000004c136f in PyEval_EvalFrameEx ()

#20 0x00000000004b9ab6 in PyEval_EvalCodeEx ()

#21 0x00000000004d54b9 in ?? ()

#22 0x00000000004eebee in ?? ()

#23 0x00000000004a577e in PyObject_Call ()

#24 0x00000000004c5e10 in PyEval_CallObjectWithKeywords ()

#25 0x0000000000589172 in ?? ()

#26 0x00007ffff7bc16ba in start_thread (arg=0x7fffe2ffd700) at

#27 0x00007ffff78f741d in clone () at


root@ros:/home/ros/zjw/ros/install/ros_x86_64/lib# grep -nrIT -e "_msg_lock"

/home/ros/zjw/ros/src/ros_comm/roscpp/include/discovery/participant.h: 144
:  std::mutex _msg_lock;

53:    std::lock_guard<std::mutex> lg(_msg_lock);

62:  std::unique_lock<std::mutex> ul(_msg_lock);


Xenomai mailing list<>

Xenomai mailing list

Reply via email to