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

Cannot access memory at address 0x8090284 #7

Closed vmayoral closed 10 years ago

vmayoral commented 10 years ago

Issue here when executing the code.

Cannot access memory at address 0x8090284

message is suspicious. Running out of memory?

vmayoral commented 10 years ago

Note the backtrace:

#0  pthread_mutex_lock (mutex=0x200071e4) at pthread/pthread_mutexlock.c:120
#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

When debugging, we clearly can't access

(gdb) x/xw 0x8090284
0x8090284 <pthread_takesemaphore+8>:    Cannot access memory at address 0x8090284

Checking the memory by hand:

0x808fff8 <pthread_mutex_lock+112>:     0xbd8046bd
(gdb) x/xw 0x808fff9
0x808fff9 <pthread_mutex_lock+112>:     0x80bd8046
(gdb) x/xw 0x808fffc
0x808fffc <pthread_mutex_trylock>:      0xb084b580
(gdb) x/xw 0x808fffd
0x808fffd <pthread_mutex_trylock>:      Cannot access memory at address 0x8090000
(gdb) x/xw 0x808fffe
0x808fffe <pthread_mutex_trylock+2>:    Cannot access memory at address 0x8090000

This address is within the 1 MB of Flash available for the STM32F4Discovery. Why is it not possible to access?

We checked the memory protection registers:

(gdb) x/xw 0xe000ed90
0xe000ed90:     0x00000800
(gdb) x/xw 0xe000ed94
0xe000ed94:     0x00000000
vmayoral commented 10 years ago

We've tried a simple "blink" program (no RTOS) and it seems that we are still not able to access those regions of memory:

(gdb) x/xw 0x808fffe
0x808fffe <pthread_mutex_trylock+2>:    Cannot access memory at address 0x8090000

Seems there might be an issue with STLINK.

vmayoral commented 10 years ago

Bug found at stlink. This https://github.com/ros2/stlink/commit/d8552796f2c630b4858eaf5613e1dc99943b572b applies the necessary changes.