From fe3bedbd3c0de6e60cdb472c26d7263f4433bc46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=82=E3=81=8F?= Date: Fri, 9 Jul 2021 02:41:22 +0300 Subject: [PATCH] Furi: proper thread id in heap tracking (#572) --- core/furi/thread.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/core/furi/thread.c b/core/furi/thread.c index 344c9511..2e22bea9 100644 --- a/core/furi/thread.c +++ b/core/furi/thread.c @@ -16,7 +16,7 @@ struct FuriThread { void* state_context; osThreadAttr_t attr; - osThreadId_t id; + volatile osThreadId_t id; bool heap_trace_enabled; size_t heap_size; @@ -37,15 +37,16 @@ void furi_thread_body(void* context) { furi_assert(thread->state == FuriThreadStateStarting); furi_thread_set_state(thread, FuriThreadStateRunning); + osThreadId_t thread_id = osThreadGetId(); if(thread->heap_trace_enabled == true) { - memmgr_heap_enable_thread_trace(thread->id); + memmgr_heap_enable_thread_trace(thread_id); } thread->ret = thread->callback(thread->context); if(thread->heap_trace_enabled == true) { - thread->heap_size = memmgr_heap_get_thread_memory(thread->id); - memmgr_heap_disable_thread_trace(thread->id); + thread->heap_size = memmgr_heap_get_thread_memory(thread_id); + memmgr_heap_disable_thread_trace(thread_id); } furi_assert(thread->state == FuriThreadStateRunning);