mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-04-19 21:11:57 -04:00
Add a stack pointer bounds check when configCHECK_FOR_STACK_OVERFLOW is set to 2.
This commit is contained in:
parent
f63bc2b5cc
commit
abef464d75
|
@ -93,12 +93,18 @@
|
||||||
const uint32_t * const pulStack = ( uint32_t * ) pxCurrentTCB->pxStack; \
|
const uint32_t * const pulStack = ( uint32_t * ) pxCurrentTCB->pxStack; \
|
||||||
const uint32_t ulCheckValue = ( uint32_t ) 0xa5a5a5a5U; \
|
const uint32_t ulCheckValue = ( uint32_t ) 0xa5a5a5a5U; \
|
||||||
\
|
\
|
||||||
|
char * pcOverflowTaskName = pxCurrentTCB->pcTaskName; \
|
||||||
if( ( pulStack[ 0 ] != ulCheckValue ) || \
|
if( ( pulStack[ 0 ] != ulCheckValue ) || \
|
||||||
( pulStack[ 1 ] != ulCheckValue ) || \
|
( pulStack[ 1 ] != ulCheckValue ) || \
|
||||||
( pulStack[ 2 ] != ulCheckValue ) || \
|
( pulStack[ 2 ] != ulCheckValue ) || \
|
||||||
( pulStack[ 3 ] != ulCheckValue ) ) \
|
( pulStack[ 3 ] != ulCheckValue ) ) \
|
||||||
{ \
|
{ \
|
||||||
char * pcOverflowTaskName = pxCurrentTCB->pcTaskName; \
|
vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pcOverflowTaskName ); \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
/* Is the currently saved stack pointer within the stack limit? */ \
|
||||||
|
if( pxCurrentTCB->pxTopOfStack <= pxCurrentTCB->pxStack + portSTACK_LIMIT_PADDING ) \
|
||||||
|
{ \
|
||||||
vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pcOverflowTaskName ); \
|
vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pcOverflowTaskName ); \
|
||||||
} \
|
} \
|
||||||
} while( 0 )
|
} while( 0 )
|
||||||
|
@ -120,10 +126,16 @@
|
||||||
\
|
\
|
||||||
pcEndOfStack -= sizeof( ucExpectedStackBytes ); \
|
pcEndOfStack -= sizeof( ucExpectedStackBytes ); \
|
||||||
\
|
\
|
||||||
|
char * pcOverflowTaskName = pxCurrentTCB->pcTaskName; \
|
||||||
/* Has the extremity of the task stack ever been written over? */ \
|
/* Has the extremity of the task stack ever been written over? */ \
|
||||||
if( memcmp( ( void * ) pcEndOfStack, ( void * ) ucExpectedStackBytes, sizeof( ucExpectedStackBytes ) ) != 0 ) \
|
if( memcmp( ( void * ) pcEndOfStack, ( void * ) ucExpectedStackBytes, sizeof( ucExpectedStackBytes ) ) != 0 ) \
|
||||||
{ \
|
{ \
|
||||||
char * pcOverflowTaskName = pxCurrentTCB->pcTaskName; \
|
vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pcOverflowTaskName ); \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
/* Is the currently saved stack pointer within the stack limit? */ \
|
||||||
|
if( pxCurrentTCB->pxTopOfStack >= pxCurrentTCB->pxEndOfStack - portSTACK_LIMIT_PADDING ) \
|
||||||
|
{ \
|
||||||
vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pcOverflowTaskName ); \
|
vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pcOverflowTaskName ); \
|
||||||
} \
|
} \
|
||||||
} while( 0 )
|
} while( 0 )
|
||||||
|
|
Loading…
Reference in a new issue