The detection framework assumes rtos->symbols is dynamically allocated,
an assumption that the ChibiOS variant breaks by providing a raw statically
allocated symbol list.
---
 src/rtos/ChibiOS.c |    7 ++++++-
 src/rtos/rtos.c    |    4 +++-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/rtos/ChibiOS.c b/src/rtos/ChibiOS.c
index b94e286..8439386 100644
--- a/src/rtos/ChibiOS.c
+++ b/src/rtos/ChibiOS.c
@@ -507,7 +507,12 @@ static int ChibiOS_get_thread_reg_list(struct rtos *rtos, 
int64_t thread_id, cha
 
 static int ChibiOS_get_symbol_list_to_lookup(symbol_table_elem_t 
*symbol_list[])
 {
-       *symbol_list = ChibiOS_symbol_list;
+       *symbol_list = malloc(sizeof(ChibiOS_symbol_list));
+
+       if (*symbol_list == NULL)
+               return ERROR_FAIL;
+
+       memcpy(*symbol_list, ChibiOS_symbol_list, sizeof(ChibiOS_symbol_list));
        return 0;
 }
 
diff --git a/src/rtos/rtos.c b/src/rtos/rtos.c
index f14e538..e745b5f 100644
--- a/src/rtos/rtos.c
+++ b/src/rtos/rtos.c
@@ -81,8 +81,10 @@ static void os_free(struct target *target)
        if (!target->rtos)
                return;
 
-       if (target->rtos->symbols)
+       if (target->rtos->symbols) {
                free(target->rtos->symbols);
+               target->rtos->symbols = NULL;
+       }
 
        free(target->rtos);
        target->rtos = NULL;
-- 
1.7.10.4


------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
OpenOCD-devel mailing list
OpenOCD-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to