Skip to content

Commit fc997f3

Browse files
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.
1 parent a9cb459 commit fc997f3

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

tasks.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2010,6 +2010,16 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
20102010
}
20112011
#endif /* portUSING_MPU_WRAPPERS */
20122012

2013+
#if ( portSTACK_GROWTH < 0 )
2014+
{
2015+
configASSERT( ( ( portPOINTER_SIZE_TYPE ) ( pxTopOfStack - pxNewTCB->pxTopOfStack ) ) < ( ( portPOINTER_SIZE_TYPE ) uxStackDepth ) );
2016+
}
2017+
#else /* portSTACK_GROWTH */
2018+
{
2019+
configASSERT( ( ( portPOINTER_SIZE_TYPE ) ( pxNewTCB->pxTopOfStack - pxTopOfStack ) ) < ( ( portPOINTER_SIZE_TYPE ) uxStackDepth ) );
2020+
}
2021+
#endif
2022+
20132023
/* Initialize task state and task attributes. */
20142024
#if ( configNUMBER_OF_CORES > 1 )
20152025
{

0 commit comments

Comments
 (0)