ros2 / ros2_embedded_nuttx

This repository isn't actively being worked on. If you would like to take over maintainership please open a ticket on https://github.com/ros2/ros2
72 stars 34 forks source link

Mutex not returning #8

Closed vmayoral closed 10 years ago

vmayoral commented 10 years ago

There's some issue in the code in this line https://github.com/vmayoral/ros2_embedded_nuttx/blob/master/nuttx/sched/pthread/pthread_mutexlock.c#L166.

#0  pthread_mutex_lock (mutex=0x200071e4) at pthread/pthread_mutexlock.c:121
#1  0x080651a0 in rcl_access (p=0x20000340 <dt_byte>) at ../../../dds/src/co/thread.c:444
#2  0x08023b50 in xt_type_delete (tp=0x20000340 <dt_byte>) at ../../../dds/src/xtypes/xtypes.c:2711
#3  0x08038338 in tsm_create_array (lp=0x100047b8, tsm=0x1000327c, iflags=0x10003288) at ../../../dds/src/xtypes/tsm.c:343
#4  0x0803854a in tsm_create_type (lp=0x100047b8, tsm=0x1000327c, iflags=0x10003288) at ../../../dds/src/xtypes/tsm.c:452
#5  0x08037e6c in tsm_create_struct_union (lp=0x100047b8, tsm=0x1000327c, iflags=0x10003288) at ../../../dds/src/xtypes/tsm.c:142
#6  0x0801e316 in DDS_DynamicType_register (tc=0x809f804 <dds_participant_msg_tsm+56>) at ../../../dds/src/xtypes/xtypecode.c:208
#7  0x0807f030 in msg_init () at ../../../dds/src/disc/disc_msg.c:193
#8  0x08081eb2 in spdp_init () at ../../../dds/src/disc/disc_spdp.c:91
#9  0x08053f02 in disc_init () at ../../../dds/src/disc/disc_main.c:992
#10 0x08015c56 in dds_init () at ../../../dds/src/dds/dds.c:1420
#11 0x08044024 in DDS_DomainParticipantFactory_create_participant (domain=0, qos=0x0, listener=0x0, mask=(unknown: 0))
    at ../../../dds/src/dcps/dcps_dpfact.c:76
#12 0x08011064 in dds_chat_main (argc=1, argv=0x10003754) at main.c:532
#13 0x0800348e in task_start () at task/task_start.c:139
#14 0x00000000 in ?? ()
vmayoral commented 10 years ago

The backtrace shared previously appears when stepping through the code. If not the following bt appears:

#0  0x08023b4c in xt_type_delete (tp=0x20000340 <dt_byte>) at ../../../dds/src/xtypes/xtypes.c:2711
#1  0x08038338 in tsm_create_array (lp=0x100047b8, tsm=0x1000327c, iflags=0x10003288) at ../../../dds/src/xtypes/tsm.c:343
#2  0x0803854a in tsm_create_type (lp=0x100047b8, tsm=0x1000327c, iflags=0x10003288) at ../../../dds/src/xtypes/tsm.c:452
#3  0x08037e6c in tsm_create_struct_union (lp=0x100047b8, tsm=0x1000327c, iflags=0x10003288) at ../../../dds/src/xtypes/tsm.c:142
#4  0x0801e316 in DDS_DynamicType_register (tc=0x809f804 <dds_participant_msg_tsm+56>) at ../../../dds/src/xtypes/xtypecode.c:208
#5  0x0807f030 in msg_init () at ../../../dds/src/disc/disc_msg.c:193
#6  0x08081eb2 in spdp_init () at ../../../dds/src/disc/disc_spdp.c:91
#7  0x08053f02 in disc_init () at ../../../dds/src/disc/disc_main.c:992
#8  0x08015c56 in dds_init () at ../../../dds/src/dds/dds.c:1420
#9  0x08044024 in DDS_DomainParticipantFactory_create_participant (domain=0, qos=0x0, listener=0x0, mask=(unknown: 0))
    at ../../../dds/src/dcps/dcps_dpfact.c:76
#10 0x08011064 in dds_chat_main (argc=1, argv=0x10003754) at main.c:532
#11 0x0800348e in task_start () at task/task_start.c:139
#12 0x00000000 in ?? ()
vmayoral commented 10 years ago

This issue needs to be further inspected. For the time being the hack at https://github.com/vmayoral/ros2_embedded_nuttx/commit/e96c6b90ee1ba7d4e9cfdf1fc65d5de2920d20ab allows to continue with development.

vmayoral commented 10 years ago

There're now two issues with the mutexes. Refer to the hack performed at https://github.com/ros2/ros2_embedded_nuttx/commit/e96c6b90ee1ba7d4e9cfdf1fc65d5de2920d20ab.

vmayoral commented 10 years ago

The last issue (second) was fixed with https://github.com/ros2/ros2_embedded_nuttx/commit/87f4e564ff99251112231de031802b9b1f687464. There still remains the issue described at the beginning.

vmayoral commented 10 years ago

Apparently the call at https://github.com/ros2/ros2_embedded_nuttx/blob/master/dds/src/dds/dds.c#L1420 requires a previous call to thread_init (in order to init rclock mutex). 3371cdf3e0503227a4fbc31c1fde7892219b2147 provides a solution.