From c92217a1099b4a1e573c2dafe81cee9ea0c1951e Mon Sep 17 00:00:00 2001 From: Sergey Gavrilov Date: Fri, 30 Sep 2022 20:59:11 +1000 Subject: [PATCH] Thread: Clear TLS after thread stop (#1807) --- furi/core/thread.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/furi/core/thread.c b/furi/core/thread.c index d326e389..d06fa8b3 100644 --- a/furi/core/thread.c +++ b/furi/core/thread.c @@ -93,14 +93,16 @@ static void furi_thread_body(void* context) { thread->name ? thread->name : ""); } - // clear thread local storage + // flush stdout __furi_thread_stdout_flush(thread); - furi_assert(pvTaskGetThreadLocalStoragePointer(NULL, 0) != NULL); - vTaskSetThreadLocalStoragePointer(NULL, 0, NULL); // from here we can't use thread pointer furi_thread_set_state(thread, FuriThreadStateStopped); + // clear thread local storage + furi_assert(pvTaskGetThreadLocalStoragePointer(NULL, 0) != NULL); + vTaskSetThreadLocalStoragePointer(NULL, 0, NULL); + vTaskDelete(NULL); furi_thread_catch(); }