From e9a2d2701eb21bda0ad81e6d6ef2750cefe913f3 Mon Sep 17 00:00:00 2001 From: Reda Maher Date: Tue, 22 Sep 2020 17:54:58 +0200 Subject: [PATCH] Posix: Free Idle task resources after ending the scheduler In case of using Posix simulator and ending the scheduler, it does not free the resources allocated by the idle task. This causes the memory checkers (Valgrind, Address Sanitizers, ..) to complain. --- portable/ThirdParty/GCC/Posix/port.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/portable/ThirdParty/GCC/Posix/port.c b/portable/ThirdParty/GCC/Posix/port.c index 086ad487a..108c1d95d 100644 --- a/portable/ThirdParty/GCC/Posix/port.c +++ b/portable/ThirdParty/GCC/Posix/port.c @@ -178,6 +178,7 @@ portBASE_TYPE xPortStartScheduler( void ) { int iSignal; sigset_t xSignals; +TaskHandle_t pxIdleThread; hMainThread = pthread_self(); @@ -185,6 +186,8 @@ sigset_t xSignals; Interrupts are disabled here already. */ prvSetupTimerInterrupt(); + pxIdleThread = xTaskGetIdleTaskHandle(); + /* Start the first task. */ vPortStartFirstTask(); @@ -197,6 +200,9 @@ sigset_t xSignals; sigwait( &xSignals, &iSignal ); } + /* Cancel the Idle task and free its resources */ + vPortCancelThread(pxIdleThread); + /* Restore original signal mask. */ (void)pthread_sigmask( SIG_SETMASK, &xSchedulerOriginalSignalMask, NULL );