Skip to content

Commit

Permalink
Add missing stack alignment adjustment if stack grows upwards (#751)
Browse files Browse the repository at this point in the history
Signed-off-by: Chien Wong <m@xv97.com>
Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com>
  • Loading branch information
ivq and aggarg authored Aug 17, 2023
1 parent bd720c3 commit b1a8511
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tasks.c
Original file line number Diff line number Diff line change
Expand Up @@ -1532,9 +1532,10 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
#else /* portSTACK_GROWTH */
{
pxTopOfStack = pxNewTCB->pxStack;
pxTopOfStack = ( StackType_t * ) ( ( ( ( portPOINTER_SIZE_TYPE ) pxTopOfStack ) + portBYTE_ALIGNMENT_MASK ) & ( ~( ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) ) ); /*lint !e923 !e9033 !e9078 MISRA exception. Avoiding casts between pointers and integers is not practical. Size differences accounted for using portPOINTER_SIZE_TYPE type. Checked by assert(). */

/* Check the alignment of the stack buffer is correct. */
configASSERT( ( ( ( portPOINTER_SIZE_TYPE ) pxNewTCB->pxStack & ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) == 0UL ) );
/* Check the alignment of the calculated top of stack is correct. */
configASSERT( ( ( ( portPOINTER_SIZE_TYPE ) pxTopOfStack & ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) == 0UL ) );

/* The other extreme of the stack space is required if stack checking is
* performed. */
Expand Down

0 comments on commit b1a8511

Please sign in to comment.