From: OpenOCD-Gerrit <ope...@us...> - 2020-03-17 16:41:04
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via aff486b6a05e1413520537d0d257e36e433754fd (commit) from dca1c6ca1f78a6a89e4274e409ff822d655add6b (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit aff486b6a05e1413520537d0d257e36e433754fd Author: Marc Schink <de...@za...> Date: Thu Feb 27 13:48:15 2020 +0100 rtos: Destroy RTOS and fix memory leak The memory leak can be reproduced by using an arbitrary RTOS and valgrind: $ valgrind --leak-check=full --show-leak-kinds=all [...] ==9656== 224 (80 direct, 144 indirect) bytes in 1 blocks are definitely lost in loss record 3 of 3 ==9656== at 0x483CD99: calloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so) ==9656== by 0x1C541A: os_alloc (rtos.c:79) ==9656== by 0x1C569E: os_alloc_create (rtos.c:111) ==9656== by 0x1C569E: rtos_create (rtos.c:153) ==9656== by 0x1AE332: target_configure (target.c:4899) ==9656== by 0x1AF228: jim_target_configure (target.c:4952) ==9656== by 0x1C9EF9: command_unknown (command.c:1066) ==9656== by 0x313284: JimInvokeCommand (jim.c:10364) ==9656== by 0x313FB6: Jim_EvalObj (jim.c:10814) ==9656== by 0x3154A3: Jim_EvalFile (jim.c:11207) ==9656== by 0x316015: Jim_SourceCoreCommand (jim.c:15230) ==9656== by 0x313284: JimInvokeCommand (jim.c:10364) ==9656== by 0x313B8B: JimEvalObjList (jim.c:10605) [...] Change-Id: I2cd41a154fb8570842601ff4e3e76502f5908f49 Signed-off-by: Marc Schink <de...@za...> Reviewed-on: http://openocd.zylin.com/5479 Tested-by: jenkins Reviewed-by: Moritz Fischer <mo...@go...> Reviewed-by: Tomas Vanek <va...@fb...> diff --git a/src/rtos/rtos.c b/src/rtos/rtos.c index 002d7b543..549833f41 100644 --- a/src/rtos/rtos.c +++ b/src/rtos/rtos.c @@ -159,6 +159,11 @@ int rtos_create(Jim_GetOptInfo *goi, struct target *target) return JIM_ERR; } +void rtos_destroy(struct target *target) +{ + os_free(target); +} + int gdb_thread_packet(struct connection *connection, char const *packet, int packet_size) { struct target *target = get_target_from_connection(connection); diff --git a/src/rtos/rtos.h b/src/rtos/rtos.h index a649e2449..c755eec29 100644 --- a/src/rtos/rtos.h +++ b/src/rtos/rtos.h @@ -111,6 +111,7 @@ struct rtos_register_stacking { #define GDB_THREAD_PACKET_NOT_CONSUMED (-40) int rtos_create(Jim_GetOptInfo *goi, struct target *target); +void rtos_destroy(struct target *target); int rtos_set_reg(struct connection *connection, int reg_num, uint8_t *reg_value); int rtos_generic_stack_read(struct target *target, diff --git a/src/target/target.c b/src/target/target.c index ceecaee10..b77400c1f 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -2049,6 +2049,8 @@ static void target_destroy(struct target *target) target->smp = 0; } + rtos_destroy(target); + free(target->gdb_port_override); free(target->type); free(target->trace_info); ----------------------------------------------------------------------- Summary of changes: src/rtos/rtos.c | 5 +++++ src/rtos/rtos.h | 1 + src/target/target.c | 2 ++ 3 files changed, 8 insertions(+) hooks/post-receive -- Main OpenOCD repository |