Add asserts to check stack overflow at task creation

This commit adds assert to allow developers to check for overflow of
undersized task stack during task creation.
This commit is contained in:
AniruddhaKanhere 2025-12-19 12:12:44 -08:00 committed by Aniruddha Kanhere
parent a9cb459206
commit 3ace38969b

10
tasks.c
View file

@ -2010,6 +2010,16 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
} }
#endif /* portUSING_MPU_WRAPPERS */ #endif /* portUSING_MPU_WRAPPERS */
#if ( portSTACK_GROWTH < 0 )
{
configASSERT( ( ( portPOINTER_SIZE_TYPE ) ( pxTopOfStack - pxNewTCB->pxTopOfStack ) ) < ( ( portPOINTER_SIZE_TYPE ) uxStackDepth ) );
}
#else /* portSTACK_GROWTH */
{
configASSERT( ( ( portPOINTER_SIZE_TYPE ) ( pxNewTCB->pxTopOfStack - pxTopOfStack ) ) < ( ( portPOINTER_SIZE_TYPE ) uxStackDepth ) );
}
#endif
/* Initialize task state and task attributes. */ /* Initialize task state and task attributes. */
#if ( configNUMBER_OF_CORES > 1 ) #if ( configNUMBER_OF_CORES > 1 )
{ {